Passwords and Encoding
Installation
1.) Install the cryptography library:
pip install cryptography
2.) Generate a secret key and save it in your .env as FERNET_KEY='...', then if you are using Heroku add the same key to Settings -> Config Vars
python -c 'from cryptography.fernet import Fernet; print(Fernet.generate_key().decode())'
models.py
Imports:
Add the encrypted password and note fields to your model (in this case the custom user profile model)
ENCRYPTED PASSWORD
forms.py
Create three separate forms (create password, update password and check password)
views.py
Imports:
Create password view
Update password view
Templates: encrypted_password.html
ENCRYPTED NOTE
Use the encrypted password to log in
forms.py
views.py
Imports:
Templates: encrypted_note.html
urls.py
Links