The javascript function that im trying to simulate: (the library im using for it is from http://www-cs-studen...w/jsbn/rsa.html
var radRSAKey = {
RSAPubKey_N: "b3f80a6b220fdaa6c08dc4dbccf1c76fdb0acfd3e5fee420797838c1c8a76849e69acdb0ebb55318f488a968335dbe0e0730f8e927ff0212c8715a5aef5bffa722b17902100e12c40b2cf65e15ea603063630887acccb9ba841fb4809b6bfbb5f61a001b7307b7fc528c51bd111e7be4082999e61fef165c4ad1503ece7d566b",
RSAPubKey_E: "10001"
}
function radEncrypt( s ){
if(s == undefined || !s) return null;
var rsa = new RSAKey();
rsa.setPublic(radRSAKey.RSAPubKey_N, radRSAKey.RSAPubKey_E);
return rsa.encrypt(s);
}
My C# attempt at simulating that:
Chilkat.Rsa rsa = new Chilkat.Rsa();
byte[] ky = Encoding.ASCII.GetBytes("b3f80a6b220fdaa6c08dc4dbccf1c76fdb0acfd3e5fee420797838c1c8a76849e69acdb0ebb55318f488a968335dbe0e0730f8e927ff0212c8715a5aef5bffa722b17902100e12c40b2cf65e15ea603063630887acccb9ba841fb4809b6bfbb5f61a001b7307b7fc528c51bd111e7be4082999e61fef165c4ad1503ece7d566b");
byte[] ky2 = Encoding.ASCII.GetBytes("10001");
string base64 = Convert.ToBase64String(ky);
string base642 = Convert.ToBase64String(ky2);
rsa.UnlockComponent("keyforthechilkatcomponent");
rsa.ImportPublicKey("<RSAKeyValue><Modulus>" + base64 + "</Modulus><Exponent>" + base642 + "</Exponent></RSAKeyValue>");
rsa.EncodingMode = "hex";
string theE = rsa.EncryptStringENC("stringiwantencrypted", false);
Now the output for each one is as follows:
Javascript (What I Want): 47af76435a51a7ab3449bcafcd85c960f2b253bbebe4b90acf173d11909bb3e5fe403a476aded386372badc026c53e895c44156f54219fd7a8875a2ded658fa4eae8a986c1ff69085b04da66c2c9ee1dc7d20b4f42e6528a07c6f0709172829d84ce32b39814ed0a69a69a23781fed48c2c4620fb0320e6b3772a167ef303671
And MY C#: Code:
5ee15a7b63dcb2474a8b35fd5d0b7c1c412355a0bf5556cbe0cb33dac44e0904baaf19cf57933f61f8d3e82f847e2bfa1a04a7bd185fba85362a9a474b9c627e4745cd7d477b2e46697c7ef0b9490ba3e335d52a972819754b7abbea8183335c8dbde0ba37dc1b199ac6e28e77576f180f5c96f868836f23e4018e3d8492b3a2350e3e923b04ddbab330bab88a47110c4110336ce28d9f797e29dbee37749114d156a19c38f89f9948422c10ada2b78ee350fc2e1f056a1419796e7453d9b02de933631e3e88aaa2b8ba989c8c5a519bdf44b23c934a1a33fa2a4a48873c202de5baed32cb2a05cd1c3c5848b69a5858f6432ae124b26ead55b631c916438aea
Now what i do notice, is that for some reason, my C# encrypted is always exactly double the length of the javascript output.
Maybe you guys have a better clue than me.
Thanks ahead of time!

New Topic/Question
Reply




MultiQuote



|