コード例 #1
0
 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)
コード例 #2
0
 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)
コード例 #3
0
 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))
コード例 #4
0
 def testDecryptReversesEncryptForUnicodeSnowman(self):
     data = '☃'
     key = crypto.getRandomKey()
     iv = crypto.getRandomIV()
     enc = crypto.encrypt(data, key, iv)
     self.assertEqual(data, crypto.decrypt(enc, key, iv))
コード例 #5
0
 def testDecrypt(self):
     key='eZNUcE1mUHoHoMW40tfRB/DaYvpWGzojDOT7S0AVOQg='
     iv='FE+fTbKvoZjIP48W/yE8Dg=='
     data = crypto.decrypt('aNbyJgtqd33gFfQrYTkobm1xD6UApyC1x7RF32Hy64w=', key, iv)
     self.assertEqual('Sally sells seashells', data)
コード例 #6
0
 def testDecryptReversesEncryptForUnicodeSnowman(self):
     data = '☃'
     key = crypto.getRandomKey()
     iv = crypto.getRandomIV()
     enc = crypto.encrypt(data, key, iv)
     self.assertEqual(data, crypto.decrypt(enc, key, iv))