Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python fernet

from cryptography.fernet import Fernet
message = "my deep dark secret".encode()

f = Fernet(key)
encrypted = f.encrypt(message)
Comment

Fernet in python

from cryptography.fernet import Fernet

data = "Here is some data I would like to encode!".encode('utf-8')
my_key = Fernet.generate_key() # keep this key safe! DO NOT LOSE IT!
# If you lose your key, any data that you encrypted and didn't decrypt
# will be lost forever. (Unless, of course, you have an excellent memory
# and can remember a 32 character long series of random and 
# cryptographically secure bytes. In which case, you're fine.)

t = Fernet(my_key)
encrypted = t.encrypt(data)
# This will return a series of bytes, so to convert it back to a string:
boring_old_string = encrypted.decode()

# If you wanted to decrypt a message:
decrypted = t.decrypt(encrypted) 
# This will return bytes, so use the method above to make it a string
Comment

PREVIOUS NEXT
Code Example
Python :: numpy evenly spaced numbers 
Python :: not equal to python 
Python :: add timestamp csv python 
Python :: python encode file 
Python :: py function 
Python :: django model query join 
Python :: tkinter mainloop 
Python :: find & replace in csv file 
Python :: python insert sorted 
Python :: python remove a character from a string 
Python :: how to make lowercase text in python 
Python :: pandas split column into multiple columns 
Python :: while true loop python 
Python :: lucky number codechef solution 
Python :: python module path 
Python :: pass 2d array to 1d python 
Python :: get data from kaggle to colab 
Python :: numpy python 3.10 
Python :: numpy arange float step 
Python :: python get attribute value with name 
Python :: add a column with initial value to an existing dataframe 
Python :: multiple inputs in one line- python 
Python :: python array of tuples for loop 
Python :: python time 
Python :: python breadth first search 
Python :: how to round to 3 significant figures in python 
Python :: python zip files 
Python :: add favicon in django admin 
Python :: py virtual 
Python :: fastest way to take screenshot python 
ADD CONTENT
Topic
Content
Source link
Name
1+6 =