crypto_6.py 405 B

123456789101112131415
  1. def encrypt(self, data):
  2. """ encrypt data with convergence encryption.
  3. Args
  4. data: str, the plain text to be encrypted
  5. Returns
  6. key: hash(block), encryption key
  7. id: hash(hash(block), block ID
  8. ciphertext: enc(key, block)
  9. """
  10. assert(isinstance(data, str))
  11. key, id = self.__sec_key(data)
  12. return key, id, aes(key, data)