I need to use some encryption mechanism in one of the projects I'm working on. I studied RSA encryption and wrote some sample programs to learn.
I understand that the size of the RSA encryption block is 16 bytes. So I gave the string "12345678" as the input to the function below:
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 has 128 bytes (256 hexadecimal characters). This line is too big for me. I kind of hoped that I would get 16 bytes of encrypted data if I give 16 bytes of simple data. Am I doing something wrong? Is this what is supposed to happen? Can I somehow reduce the encrypted data?
source
share