SpecialistOff.NET / Вопросы / Статьи / Фрагменты кода / Резюме / Метки / Помощь / Файлы

Список вопросов Печать

Как создать хеш пароля?


Метки: python perl sha-512 

Ответы

RemiZOffAlex  Создано: 2019-06-18 17:57:14.466073  Обновлено: 2019-06-18 17:57:14.466073

Python

Вариант I

python -c 'import crypt; print crypt.crypt("PASSWORD", "$6$random_salt")'

Вариант II

import crypt
import string
import random

alphabet = string.digits + string.ascii_letters
password = ''
salt = ''

for i in range(16):
    password += random.choice(alphabet)
    salt += random.choice(alphabet)

print(password)
print(crypt.crypt(password, "$6$" + salt))

Вариант III

python3 - <<EOF
import crypt
import string
import random

alphabet = string.digits + string.ascii_letters
password = ''
salt = ''

for i in range(16):
    password += random.choice(alphabet)
    salt += random.choice(alphabet)

print(password)
print(crypt.crypt(password, "\$6\$" + salt))
EOF

Perl

perl -e 'print crypt("PASSWORD","\$6\$random_salt\$") . "\n"'

Возможно будут интересны и другие вопросы