Make sure to use the same salt every time you convert a password to a key otherwise it will not produce the same result. You can generate a new salt using os.urandom(16). It is recommended to use a different salt than the one shown here. The variable key will now have the value of a url safe base64 encoded key. derive ( password )) # Can only use kdf once SHA256 (), length = 32, salt = salt, iterations = 100000, backend = default_backend () ) key = base64. encode () # Convert to type bytes salt = b 'salt_' # CHANGE THIS - recommend using a key from os.urandom(16), must be of type bytes kdf = PBKDF2HMAC ( algorithm = hashes. Import base64 from import default_backend from import hashes from .pbkdf2 import PBKDF2HMAC password_provided = "password" # This is input in the form of a string password = password_provided.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |