File size: 360 Bytes
1f72938
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
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