示例#1
0
 def test_decrypt_invalid_encrypted(self):
     # "stuff" is not decryptable.
     encrypted = bin_to_b64(b"stuff")
     with self.assertRaises(ValueError):
         decrypt_binary(encrypted, self.key)
示例#2
0
 def test_encrypt_and_decrypt_long(self):
     value = b"0" * 1_000_000
     self.assertEqual(
         decrypt_binary(encrypt_binary(value, self.key), self.key), value)
示例#3
0
 def test_decrypt_invalid_base64(self):
     encrypted = encrypt_binary(b"stuff", self.key)
     with self.assertRaises(ValueError):
         decrypt_binary(encrypted[1:], self.key)
示例#4
0
 def test_encrypt_and_decrypt(self):
     self.assertEqual(
         decrypt_binary(encrypt_binary(b"stuff", self.key), self.key),
         b"stuff")
示例#5
0
 def test_encrypt_and_decrypt_empty(self):
     self.assertEqual(
         decrypt_binary(encrypt_binary(b"", self.key), self.key), b"")
示例#6
0
 def test_decrypt_invalid_encrypted(self):
     # "stuff" is not decryptable.
     encrypted = bin_to_b64(b"stuff")
     with self.assertRaises(ValueError):
         decrypt_binary(encrypted, self.key)
示例#7
0
 def test_encrypt_and_decrypt_long(self):
     self.assertEqual(
         decrypt_binary(encrypt_binary(b"0" * 1000000, self.key), self.key),
         b"0" * 1000000)
示例#8
0
 def test_decrypt_invalid_base64(self):
     encrypted = encrypt_binary(b"stuff", self.key)
     with self.assertRaises(ValueError):
         decrypt_binary(encrypted[1:], self.key)
示例#9
0
 def test_encrypt_and_decrypt_long(self):
     value = b"0" * 1_000_000
     self.assertEqual(
         decrypt_binary(encrypt_binary(value, self.key), self.key),
         value)
示例#10
0
 def test_encrypt_and_decrypt_empty(self):
     self.assertEqual(
         decrypt_binary(encrypt_binary(b"", self.key), self.key),
         b"")
示例#11
0
 def test_encrypt_and_decrypt(self):
     self.assertEqual(
         decrypt_binary(encrypt_binary(b"stuff", self.key), self.key),
         b"stuff")
示例#12
0
文件: crypto_test.py 项目: Nyrio/cms
 def test_encrypt_and_decrypt_long(self):
     self.assertEqual(
         decrypt_binary(encrypt_binary(b"0" * 1000000, self.key), self.key),
         b"0" * 1000000)