hf-similarity-check / data_encryption.py
Mitul Mohammad Abdullah Al Mukit
first commit
1f72938
raw
history blame
360 Bytes
import base64
import rsa
with open("pubkey.pem", 'rb') as f:
pubKey = rsa.PublicKey.load_pkcs1(f.read())
def encrypt(data):
for key, value in data.items():
value_bytes = value.encode("utf-8")
encrypted_value = rsa.encrypt(value_bytes, pubKey)
encoded_value = base64.b64encode(encrypted_value)
data[key] = encoded_value