Exemplo n.º 1
0
 def test_encryption(self):
     """
     Tests that encryption and decryption are sane
     """
     message = u"Hello, Nudge Encryption!"
     key = generate_key()
     encrypted, iv = encrypt(key.decode('hex'), message)
     decrypted = decrypt(key.decode('hex'), encrypted, iv)
     self.assertEqual(message, decrypted.strip())
Exemplo n.º 2
0
 def test_encryption(self):
     """
     Tests that encryption and decryption are sane
     """
     message=u"Hello, Nudge Encryption!"
     key=generate_key()
     encrypted, iv = encrypt(key.decode('hex'), message)
     decrypted= decrypt(key.decode('hex'), encrypted, iv)
     self.assertEqual(message, decrypted.strip())
Exemplo n.º 3
0
def encrypt_batch(key, b_plaintext):
    """Encrypts a pickled batch for sending to server"""
    encrypted, iv = encrypt(key, b_plaintext)
    return {'batch': encrypted, 'iv': iv.encode('hex')}