Skip to content

Instantly share code, notes, and snippets.

@YiLi225
Created February 26, 2023 05:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save YiLi225/931bd7fd8d455cb0d555b39ade5038df to your computer and use it in GitHub Desktop.
Save YiLi225/931bd7fd8d455cb0d555b39ade5038df to your computer and use it in GitHub Desktop.
## Encrpyt the data file
# opening the key
with open('filekey.key', 'rb') as filekey:
key = filekey.read()
# using the generated key
fernet = Fernet(key)
# opening the original file to encrypt
with open('Wine_data.csv', 'rb') as file:
original = file.read()
# encrypting the file
encrypted = fernet.encrypt(original)
# opening the file in write mode and
# writing the encrypted data
with open('Wine_data_encrypted.csv', 'wb') as encrypted_file:
encrypted_file.write(encrypted)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment