Forge.min.js RSA encryption in C#

做~自己de王妃 提交于 2020-03-25 19:38:15

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!