Okay, so I wanted to mess around with CFB (Cipher Feedback) mode encryption, specifically something called “CFB-8” or “CFB bite” as some folks call it. I’ve been hearing about it and how it’s a bit different from the usual block cipher modes, so I figured, why not give it a shot?
First, I needed some basic encryption tools. I’m no cryptography expert, so I just grabbed a common library. In my case,I dabbled with a few, because I wanted to use in python, finally I chose pycryptodome.
Getting Started
- I installed pycryptodome. that’s easy to do, I opened the terminal directly, then I keyed in the “pip install pycryptodome”.
Next up, I needed some code. I’m not about to write all that encryption stuff from scratch! I found some examples online, and after a bit of tweaking, I got something that looked like it should *’s my habit that keeping the original code, because that’s easy to forget.
The Experiment
I started with a simple message, just “Hello, world!” or something like that. Nothing fancy. The whole point was to see how CFB-8 actually handled the data, byte by byte.
Then I picked an encryption key and an initialization vector (IV). You gotta have those for this kind of thing. I just used random ones for this test, but obviously, in a real situation, you’d want to be more careful.
I fed my message into the encryption function, one byte at a time. That’s the key difference with CFB-8 – it works on individual bytes, not big blocks of data. And I watched.and I printed out each encrypted byte as it came out. It looked like a bunch of gibberish, of course, but that’s the whole point!
After encrypting, I took that gibberish and fed it into the decryption function, again one byte at a time. And guess what? Out popped my original message, “Hello, world!”. It worked!
My Observations
It was pretty cool to see how each byte affected the next one. That’s the “feedback” part of CFB. A change in one byte ripples through and changes the rest of the encrypted data. That’s different from some other modes, where a single bit flip only messes up one block.
I also played around with flipping a bit in the ciphertext. Just changed one of the encrypted bytes to see what would happen. When I decrypted it, the corresponding byte in the plaintext was messed up, as expected. But – and this is important – the rest of the message after that byte was also messed up. That’s the feedback in action again.
And that’s the way I finally get my “cfb bite” running successfully, it’s byte by byte encryption, not a whole bunch.