Make crypto module python3-compatible
* Remove usage of unicode() and decode the base64-encoded string in
encrypt();
* Encode the string received in decrypt() as (I supposed) it should come
from the result of encrypt().
Add tests for this module along the way.
from unittest import TestCase
from cubicweb import crypto
class CryptoTC(TestCase):
def test_encrypt_decrypt_roundtrip(self):
data = {'a': u'ah', 'b': [1, 2]}
seed = 'ssss'
crypted = crypto.encrypt(data, seed)
decrypted = crypto.decrypt(crypted, seed)
self.assertEqual(decrypted, data)
if __name__ == '__main__':
import unittest
unittest.main()