def test_get_logins(self): key = crypto.get_random_key() iv = crypto.get_random_iv() requestor = mock.Mock( return_value={ 'Entries': [{ 'key': crypto.encrypt(b'test', key, iv) }], 'Nonce': iv, }) logins = protocol.get_logins('a', 'b', key, requestor) logins = [{'key': crypto.decrypt(logins[0]['key'], key, iv)}] self.assertEqual([{'key': b'test'}], logins)
def test_decrypt(self): key = 'eZNUcE1mUHoHoMW40tfRB/DaYvpWGzojDOT7S0AVOQg=' iv = 'FE+fTbKvoZjIP48W/yE8Dg==' data = crypto.decrypt(b'aNbyJgtqd33gFfQrYTkobm1xD6UApyC1x7RF32Hy64w=', key, iv) self.assertEqual(b'Sally sells seashells', data)
def test_decrypt_reverses_encrypt_for_unicode_snowman(self): data = bytes('☃', 'utf-8') key = crypto.get_random_key() iv = crypto.get_random_iv() enc = crypto.encrypt(data, key, iv) self.assertEqual(data, crypto.decrypt(enc, key, iv))
def testDecryptReversesEncryptForUnicodeSnowman(self): data = '☃' key = crypto.getRandomKey() iv = crypto.getRandomIV() enc = crypto.encrypt(data, key, iv) self.assertEqual(data, crypto.decrypt(enc, key, iv))
def testDecrypt(self): key='eZNUcE1mUHoHoMW40tfRB/DaYvpWGzojDOT7S0AVOQg=' iv='FE+fTbKvoZjIP48W/yE8Dg==' data = crypto.decrypt('aNbyJgtqd33gFfQrYTkobm1xD6UApyC1x7RF32Hy64w=', key, iv) self.assertEqual('Sally sells seashells', data)