Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PaddingMode is undefined #9

Open
ghost opened this issue Dec 6, 2019 · 0 comments
Open

PaddingMode is undefined #9

ghost opened this issue Dec 6, 2019 · 0 comments

Comments

@ghost
Copy link

ghost commented Dec 6, 2019

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;
    }

`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants