问题
I am trying to use Forge.min.js encryption method to encrypt one of my key, the encryption look like this in Javascript
EncryptPassword: function (Password, exponent,modulus)
{
modulus = new forge.jsbn.BigInteger(modulus,16);
exponent = new forge.jsbn.BigInteger(exponent, 16);
var publicKey = forge.pki.setRsaPublicKey(modulus, exponent);
return publicKey.encrypt(Password);
}
This is the function that i used in forge.min.js. My problem is that i cant load the js file in c# console, whenever i load the Js file using the method below :
MSScriptControl.ScriptControlClass sc = new MSScriptControl.ScriptControlClass();
sc.Language = "javascript";
sc.AddCode(File.ReadAllText(@"C:\forge-min.js"));
when i load the forge-min.js file using the above method in c# console, it goes to exception with message "Expected Identifier". My question is is there a method to encrypt in c# that produce the same result. Or is there a method that is able to load forge-min.js
*Note: forge-min.js file is in here https://cdnjs.cloudflare.com/ajax/libs/forge/0.9.1/forge.min.js
来源:https://stackoverflow.com/questions/60537075/forge-min-js-rsa-encryption-in-c-sharp