I have a 6 digit decimal integer whose range is 0 to 999999. I have a 128 bit key. How can I encrypt the number and have a result that is smaller than 8 bytes? I have tried a few samples from MSDN and I end up with a 16 or 8 byte result. Is getting a result with more like 12 digits or fewer possible?
Asked
Active
Viewed 800 times
2 Answers
1
Convert the decimal into a byte array and xor it with the key. This is essentially a One-time pad.
Other than that, basically all stream ciphers can do what you want. For example AES in CTR mode or RC4.
-
One-time pad is brilliant and fascinating. – JohnWrensby Mar 09 '15 at 20:58
-
You really have to keep in mind the *one-time* part of OTP. Although this is not in the name, stream ciphers without a nonce (which blows up the ciphertext and may break your requirement of it being smaller than 8 bytes) have the same problem that the key can be used only once. – Artjom B. Mar 09 '15 at 21:08