Ich habe ein Problem, Modulo Parameter in RSAParameter setzen. Ich konvertiere meinen öffentlichen Schlüssel String in Byte-Array und mein Problem ist, dass die Länge zu lang ist.Set Modul RSA Parameter von öffentlichen String-Schlüssel
byte[] lExponent = { 1, 0, 1 };
//Create a new instance of the RSACryptoServiceProvider class.
RSACryptoServiceProvider lRSA = new RSACryptoServiceProvider();
//Create a new instance of the RSAParameters structure.
RSAParameters lRSAKeyInfo = new RSAParameters();
//Set RSAKeyInfo to the public key values.
string KeyString = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCV/eUrmhIZul32nN41sF0y/k4detUxPTQngHFQGOoQNCRa84+2mGdCAg3EN9DPsUtCSHjscfp5xC9otgZsj13Rn7atbGZhJn5eZpIzPZV/psfeueL0Idq7b1msyBNG8dqR0WblYvzSY8uWwIIWyOkrQvtUwHJoxrBD4iLO/NEvzQIDAQAB";
PublicKey = Convert.FromBase64String(KeyString);
lRSAKeyInfo.Modulus = PublicKey;
lRSAKeyInfo.Exponent = lExponent;
lRSA.ImportParameters(lRSAKeyInfo);
return Convert.ToBase64String(lRSA.Encrypt(InputStringbytes, false));
Die problim ist, dass meine Schlüsselgröße 1296 und nicht 1024. I mit XMLParameter String getestet haben, aber ich habe das gleiche Problem.
Ich brauche Hilfe. Danke pro Fortschritt
Normalerweise ist der öffentliche Schlüssel gut, denn mit Bibliothek JavaScript, um die öffentlichen Schlüssel der Arbeit (https://github.com/travist/jsencrypt). Ich möchte seine Bibliothek nicht verwenden, sondern die Verschlüsselung in .NET realisieren. Für mich ist es mein Code funktioniert nicht. – Christophe