Porting C# Aes Encryption To Javascript For Node.js
Looking for help to port below C# code into Node.js using crypto or equivalent module. private string password='FlU4c8yQKLkYuFwsgyU4LFeIf7m3Qwy+poMBdULEMqw='; private byte[] salt
Solution 1:
these codes parts are generating same the result.
but i did not get 'GZlqgdLbMQ753dTmx1nlJ6HgdabTjW1CeCSoIYkLM4E=' result from c#.
c#
byte[] password= Convert.FromBase64String("FlU4c8yQKLkYuFwsgyU4LFeIf7m3Qwy+poMBdULEMqw=");
byte[] salt = Encoding.ASCII.GetBytes("##oEDA102ExChAnGe99#$#");
Rfc2898DeriveBytespdb=newRfc2898DeriveBytes(password,salt,1000);
stringpdbStr=Convert.ToBase64String(pdb.GetBytes(32));
Console.WriteLine(pdbStr);
//outpu : RMqDMSV6d8uT2NicGM212r3KMFt7ZsOI2q8+0Rr0WZQ=
JS
var crypto = require("crypto");
var password = "FlU4c8yQKLkYuFwsgyU4LFeIf7m3Qwy+poMBdULEMqw=";
var salt = "##oEDA102ExChAnGe99#$#";
crypto.DEFAULT_ENCODING = 'base64';
var pdbBytes = crypto.pbkdf2Sync(newBuffer(password,'base64'), salt, 1000, 32,'sha1');
var pdbStr = newBuffer(pdbBytes).toString()
console.log("pdbStr", pdbStr);
//outpu : RMqDMSV6d8uT2NicGM212r3KMFt7ZsOI2q8+0Rr0WZQ=
Post a Comment for "Porting C# Aes Encryption To Javascript For Node.js"