トップ 一覧 検索 ヘルプ 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 + "$") )