Skip to content

Commit

Permalink
Create encryption.py
Browse files Browse the repository at this point in the history
  • Loading branch information
KOSASIH authored May 11, 2024
1 parent 05a8dec commit 7d0febc
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions security/encryption.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from cryptography.fernet import Fernet

def encrypt_data(data, key):
# Encrypt data using PyCrypto or cryptography

f = Fernet(key)
encrypted_data = f.encrypt(data.encode())

return encrypted_data

def decrypt_data(encrypted_data, key):
# Decrypt data using PyCrypto or cryptography

f = Fernet(key)
decrypted_data = f.decrypt(encrypted_data).decode()

return decrypted_data

0 comments on commit 7d0febc

Please sign in to comment.