clach04/chi_io

refactor - reduce duplicated code for both encryption and decryption

Closed this issue · 0 comments

For the different APIs, class versus file IO functions. See #12

  • use PEP272LikeCipher() in read enc file function, read_encrypted_file()
  • use PEP272LikeCipher() in write enc file function write_encrypted_file()

NOTE comments in code on behavior differences:

[PEP272LikeCipher.decrypt()]code is almost identical to the code currently in read_encrypted_file(), difference is ChiIO exceptions are should catch all issues - RunTime exception is not raised unlike read_encrypted_file() for some bad inputs

in decrypt, for padding read issues:

  • function raises RuntimeError()
  • class raises UnsupportedFile()

Both raise BadPassword() but file code attempts to report filename.

file code also complains on missing password.