node.js how to repreduce PHP MD5 encryption -
i'm converting existing php based website node.js app, , need reproduce encryption method php js.
private static $_passwordsalt = 'd2g6iop(u(&§)%u§vuipu(hn%v/§§urerjh0ürfqw4zoöqe54gß0äq"lou$3wer'; public static function getcryptedpassword($password = 'password') {     return sha1(md5(self::$_passwordsalt.$password)); }   so far i've tried not return same results:
userschema.methods.hashpassword = function(password) {         var salt = 'd2g6iop(u(&§)%u§vuipu(hn%v/§§urerjh0ürfqw4zoöqe54gß0äq"lou$3wer'         var md5hash = md5(password + salt);         var hash = sha1(md5hash);         return hash; };      
please try these:
    var crypto = require('crypto'); var salt = 'd2g6iop(u(&§)%u§vuipu(hn%v/§§urerjh0ürfqw4zoöqe54gß0äq"lou$3wer' var password = 'pass';  var hashmd5 = crypto.createhash('md5').update(salt + password).digest("hex"); var hassha1 = crypto.createhash('sha1').update(hasmd5).digest("hex"); console.log(hashsha1);   as file: hash.js
and hash.php these code:
<?php  $_passwordsalt = 'd2g6iop(u(&§)%u§vuipu(hn%v/§§urerjh0ürfqw4zoöqe54gß0äq"lou$3wer'; $password = 'pass';  //echo md5("phinware"); echo sha1(md5($_passwordsalt.$password)); echo "\n";   and execute both files:
- > php hash.php
 - > node hash.js
 
my results:
both: 3cbd1242e8e510a16f39d7e0bfd18a0e03d0de3f
Comments
Post a Comment