Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save tetsuyainfra/93ef2e54e98972b2a3f9d3d10d70e6b1 to your computer and use it in GitHub Desktop.
Save tetsuyainfra/93ef2e54e98972b2a3f9d3d10d70e6b1 to your computer and use it in GitHub Desktop.
ハッシュ化されたパスワードの生成方法 python
#!/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