I need to use some encryption mechanism in one of the project I am working on. I was exploring RSA encryption and wrote some sample programs to learn.
I understand that block size of RSA encryption is 16 bytes. So I gave the string "12345678" as input to below function:
public static string Encrypt (string input) { var byteConverter = new UnicodeEncoding (); RSACryptoServiceProvider cruptoEngine = new RSACryptoServiceProvider(); byte[] output = cruptoEngine.Encrypt (byteConverter.GetBytes (input), false); return BytesToString (output); //BytesToString () converts the bytes to hex string }
Now the encrypted string that I get is of 128 bytes (256 hex characters). This string is too big for me. I was kind of hoping that I would get 16 bytes of encrypted data if I give 16 bytes of plain data. Am I doing something wrong? Is this what is supposed to happen? Can I somehow shorten encrypted data?