Encrypted data size using RSA encryption (RSACryptoServiceProvider)

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?

+3
source share
1 answer

You are wrong. RSA is not a block cipher, so you cannot talk about its size.

RSA- , RSA. - RSA , ( ) . , -, 1024- , .

AES. RSA , AES .

AES - - 16 , ( , ) 16 16 .

+12

Source: https://habr.com/ru/post/1705401/


All Articles