def symmetric_enc(message, key):
    return [(ord(char) ^ key) for char in message]

def symmetric_dec(cipher, key):
    return ''.join(num ^ key for num in cipher)

def asymmetric_enc(message, pubkey):
    msg = [ord(char) for char in message]
e, n = pubkey
c = [(m ** e % n) for m in msg]
return c

def asymmetric_dec(cipher, prikey):
    d, n = prikey
msg = [(c ** d % n) for c in cipher]
msg = [chr(m) for m in msg]
message = ''.join(msg)
return message

def enc(message, pubkey):
    session_key = random.randrange(1, 256)
return asymmetric_enc(session_key, pubkey), symmetric_enc(message, session_key)

def dec(message, prikey):
    session_key, body = message
session_key = asymmetric_dec(session_key, prikey)
return symmetric_dec(body, session_key)
Добавьте случайности в простой пример шифрования RSA