I'm trying to encrypt something simple, like int or long. Simplest way I found looks like:
int num = 2;
RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();
byte[] numBytes = BitConverter.GetBytes(num);
byte[] encryptedBytes = rsa.Encrypt(numBytes, true);
Problem is, the encryptedBytes is 128 bytes long. How can I encrypt data (which I could still later decrypt) where the encrypted result is the same length in bytes as the input?
I know I can shorten the result if I define RSACryptoServiceProvider(512) or RSACryptoServiceProvider(384), but that's as low as it goes.
I need 4 or 8 bytes going in, and 4 or 8 bytes coming out (respectively)
Thanks!
*** Clarification:
I want to encrypt something small (ie 4 or 8 bytes) and obtain a result of a similar size. What's the simplest way to do it in C# while still using some key (with the built in libraries) rather than some mod and shift operations