トップ 差分 一覧 ソース 検索 ヘルプ RSS ログイン

PRG-PY-passwd

  pw key

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import getpass
import crypt
import hashlib
import random

pw = getpass.getpass()
## salt = hashlib.sha1(str(random.random())).hexdigest()
# salt = hashlib.sha256(b'test').hexdigest()
salt = hashlib.sha1(bytes(random.randint(32,90))).hexdigest()
print ( crypt.crypt( pw , "$1$" + salt + "$") )