Created
March 19, 2017 18:10
-
-
Save tetsuyainfra/93ef2e54e98972b2a3f9d3d10d70e6b1 to your computer and use it in GitHub Desktop.
ハッシュ化されたパスワードの生成方法 python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/env python | |
# 一番強いハッシュ関数とランダムにソルトを選んでくれる | |
# python -c 'import crypt; print crypt.crypt("password")' | |
# 上に同じ | |
# python -c 'from crypt import crypt,mksalt; s=mksalt(); print crypt("password",s)' | |
# SHA-512指定,ソルトはランダム | |
#python -c 'from crypt import crypt,mksalt,METHOD_SHA512; s=mksalt(METHOD_SHA512); print crypt("password",s)' | |
import crypt | |
salt = crypt.mksalt(crypt.METHOD_SHA512) | |
salt = crypt.mksalt(crypt.METHOD_SHA256) | |
salt = crypt.mksalt(crypt.METHOD_MD5) | |
salt = crypt.mksalt(crypt.METHOD_CRYPT) | |
print crypt.crypt("password", salt) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment