Beispiel #1
0
def decrypt_text(text, secret_key, sender_public_key):
    """Decrypts a text
    """
    secret_key = PrivateKey(secret_key.decode('hex'))
    sender_public_key = PublicKey(sender_public_key.decode('hex'))
    box = Box(secret_key, sender_public_key)
    return box.decrypt(text)
Beispiel #2
0
def encrypt_text(text, secret_key, rcpt_public_key):
    """Encrypts a text
    """
    secret_key = PrivateKey(secret_key.decode('hex'))
    rcpt_public_key = PublicKey(rcpt_public_key.decode('hex'))
    box = Box(secret_key, rcpt_public_key)
    return box.encrypt(text, nacl.utils.random(Box.NONCE_SIZE))