3 ms·
I had this in mind recently when doing the Cryptopals challenge, which requires you to implement the Counter mode of block encryption[1]. In that case, encrypt
by SilasX 8y ago
I had this in mind recently when doing the Cryptopals challenge, which requires you to implement the Counter mode of block encryption[1]. In that case, encryption is the same mathematical operation as decryption. I still figured I should have two different functions for encryption vs decryption to make it more obvious which variables are intended to hold a plaintext vs ciphertext.
[1] https://en.wikipedia.org/wiki/Block_cipher_mode_of_operation#Counter_(CTR) https://en.wikipedia.org/wiki/Block_cipher_mode_of_operation...
- tedunangst 8y agoDepends on language, but if the type system supports encrypted and plaintext types/traits, this is the way to go.
- SilasX 8y agoGood point, I didn't think of that! That would be a better way to do it! (At least in some respects.)
- ta7394958 8y agoOff topic, but I'd highly recommend that Cryptopals set of challeges for anyone that likes a coding challenge and wants to dip their hairy toes in encryption. Eudyptula one also cool; I think last time it came up there was a list of some similar ones. I find that a particularly good way of learning (at least over plain reading/coding).