Remove encryptEasy
and decryptEasy
; both functions are insecure and only serve to confuse possible users.
Your padding implementation is incorrect ifcurrent scheme doesn't use a MAC, not a checksum which means the data already contains null bytesciphertext is unauthenticated. (Use PKCS#7)This is a bad idea. It is recommended to use a HMAC function for authentication, in order to also avoid the risk of hash extension attacks while keeping the output range large.
Encrypt-then-MAC is recommended, sincewhile your current implementationapproach is hash-then-encrypt which is theoretically vulnerable to CTR bitflipping attacks.
Your padding implementation is incorrect if the data already contains null bytes (Use PKCS#7).
Instead of using a reference param for exceptions, just throw exceptions directly.