我有一個問題,在RSAParameter中設置模參數。 我轉換我的公鑰字符串在字節數組中,我的問題是長度太長。設置模數RSA參數從字符串公鑰
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));
問題是我的密鑰大小是1296而不是1024.我用XMLParameter字符串進行了測試,但我遇到了同樣的問題。
我需要幫助。感謝每一個前進
通常情況下,公鑰是好的,因爲與庫中的JavaScript公鑰工作(https://github.com/travist/jsencrypt)。我想不要使用他的庫,但在.NET中實現加密。對我來說,這是我的代碼不起作用。 – Christophe