Deduplicate code for ECB encryption and decryption