On macOS you should not use the versions above, because Python uses the system's version of crypt() which does not behave the same and uses insecure DES encryption. If you are using a Mac, see the comment about using this in python on a mac where it doesn't seem to work as expected. Update 1: The string produced is suitable for shadow and kickstart scripts. I'd recommend you look up what salts are and such and as per smallclamgers comment the difference between encryption and hashing. 2a -> Blowfish (not in mainline glibc added in some Linux distributions). The ID of the hash (number after the first $) is related to the method used: MD5, SHA256, and SHA512), it will use the strongest available. If you don't provide an argument to crypt.mksalt (it could accept crypt.METHOD_CRYPT. Python 3.3+ includes mksalt in crypt, which makes it much easier (and more secure) to use: python3 -c 'import crypt print(crypt.crypt("test", crypt.mksalt(crypt.METHOD_SHA512)))' Here's a one liner: python -c 'import crypt print crypt.crypt("test", "$6$random_salt")' Edit: Please note this answer is 10+ years old.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |