-
Notifications
You must be signed in to change notification settings - Fork 20
Open
Description
I try to implement the library; the RSA encryption in a project, I copied the example and run the project but don´t work, It show me this error;
TypeError: System.Security.Cryptography.PaddingMode is undefined
This is the code that I used:
function GetNewRsaProvider(dwKeySize) {
// Create a new instance of RSACryptoServiceProvider.
if (!dwKeySize) dwKeySize = 512;
return new System.Security.Cryptography.RSACryptoServiceProvider(dwKeySize);
}
function GetRsaKey(includePrivateParameters) {
var keyParams = xmlParamsDefault;
// ------------------------------------------------
// RSA Keys
// ------------------------------------------------
var rsa = GetNewRsaProvider();
if (keyParams[0] === "<") {
// Import parameters from xml.
rsa.FromXmlString(keyParams);
} else {
var keyBlob = System.Convert.FromBase64String(keyParams);
rsa.ImportCspBlob(keyBlob);
}
return rsa.ExportParameters(includePrivateParameters);
}
function fn_encriptar(Texto, Grifo) {
var decryptedBytes = System.Text.Encoding.UTF8.GetBytes(Texto);
var doOaepPadding = false;
// ------------------------------------------------
// Encrypt
// ------------------------------------------------
var rsa = GetNewRsaProvider();
// Import the RSA Key information.
rsa.ImportParameters(GetRsaKey(false));
// Encrypt the passed byte array and specify OAEP padding.
var encryptedBytes = rsa.Encrypt(decryptedBytes, doOaepPadding);
var encryptedString = System.Convert.ToBase64String(encryptedBytes)
// ------------------------------------------------
// Display the encrypted data.
//var encryptedString = System.BitConverter.ToString(encryptedBytes, "");
return encryptedString;
}
`
Metadata
Metadata
Assignees
Labels
No labels