Skip to content

PaddingMode is undefined #9

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions