Created
February 21, 2018 13:51
-
-
Save thomseddon/1479603cac5b70ceaa5f9397f850eaf3 to your computer and use it in GitHub Desktop.
crypt mksalt for python 2
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
import string as _string | |
from random import SystemRandom as _SystemRandom | |
_saltchars = _string.ascii_letters + _string.digits + './' | |
_sr = _SystemRandom() | |
# SHA512 mksalt extracted from https://github.com/python/cpython/blob/master/Lib/crypt.py | |
def mksalt(): | |
return '$6$' + ''.join(_sr.choice(_saltchars) for char in range(16)) | |
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
import mksalt | |
print(crypt.crypt('secret', mksalt.mksalt())) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment