Example #1
0
 def test_encrypt_decrypt(self):
     key1 = "12345678"
     key2 = "12345679"
     for text in ("some text", "blabla", "12=213"):
         encrypted_text = encrypt(text, key1)
         self.assertEqual(text, decrypt(encrypted_text, key1))
         self.assertNotEqual(text, decrypt(encrypted_text, key2))
Example #2
0
 def create_token(self):
     """Create a time-stamped token"""
     timestamp = int(time.time())
     message = '%s:%s' % (timestamp, self.signature)
     return crypto.encrypt(message, self.encryption_key)