Exemple #1
0
 def test_encrypt_chaining(self):
     # Even if the input is repeated, the output should not be.
     encrypted = encrypt_binary(b"0" * 1_000_000, self.key)
     # The output should appear random, so any sequence of 64 bytes is
     # very unlikely to repeat.
     blocks = re.findall(".{64}", encrypted)
     self.assertEqual(len(blocks), len(set(blocks)))
Exemple #2
0
 def test_encrypt_chaining(self):
     # Even if the input is repeated, the output should not be.
     encrypted = encrypt_binary(b"0" * 1000000, self.key)
     # The output should appear random, so any sequence of 64 bytes is
     # very unlikely to repeat.
     blocks = re.findall(".{64}", encrypted)
     self.assertEqual(len(blocks), len(set(blocks)))
Exemple #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)
Exemple #4
0
 def test_encrypt_salting(self):
     self.assertNotEqual(encrypt_binary(b"stuff", self.key),
                         encrypt_binary(b"stuff", self.key))
Exemple #5
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)
Exemple #6
0
 def test_encrypt_and_decrypt_empty(self):
     self.assertEqual(
         decrypt_binary(encrypt_binary(b"", self.key), self.key), b"")
Exemple #7
0
 def test_encrypt_and_decrypt(self):
     self.assertEqual(
         decrypt_binary(encrypt_binary(b"stuff", self.key), self.key),
         b"stuff")
Exemple #8
0
 def test_encrypt_and_decrypt_long(self):
     self.assertEqual(
         decrypt_binary(encrypt_binary(b"0" * 1000000, self.key), self.key),
         b"0" * 1000000)
Exemple #9
0
 def test_decrypt_invalid_base64(self):
     encrypted = encrypt_binary(b"stuff", self.key)
     with self.assertRaises(ValueError):
         decrypt_binary(encrypted[1:], self.key)
Exemple #10
0
 def test_encrypt_salting(self):
     self.assertNotEqual(encrypt_binary(b"stuff", self.key),
                         encrypt_binary(b"stuff", self.key))
Exemple #11
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)
Exemple #12
0
 def test_encrypt_and_decrypt_empty(self):
     self.assertEqual(
         decrypt_binary(encrypt_binary(b"", self.key), self.key),
         b"")
Exemple #13
0
 def test_encrypt_and_decrypt(self):
     self.assertEqual(
         decrypt_binary(encrypt_binary(b"stuff", self.key), self.key),
         b"stuff")
Exemple #14
0
 def test_encrypt_and_decrypt_long(self):
     self.assertEqual(
         decrypt_binary(encrypt_binary(b"0" * 1000000, self.key), self.key),
         b"0" * 1000000)