Удалите последний измененный файл

Вы можете сохранить сгенерированный пароль в переменной и записать его в два файла:

  • Один файл в открытом виде
  • Один файл хеширован

Например:

# initialize (truncate) output files
> clear.txt
> hashed.txt

cut -d: -f1 pw.txt | while read -r user; do        
    # generate a hash from a random number
    hash=$(openssl passwd $RANDOM)

    # use the first 8 letters of the hash as the password
    pass=${hash:0:8}

    # write password in clear formats to one file, and hashed in another
    echo "$user:$pass" >> clear.txt
    echo "$user:$(openssl passwd $pass)" >> hashed.txt
done
1
22.03.2016, 01:36
0 ответов

Теги

Похожие вопросы