wildduck/lib/md5
2018-09-11 16:03:54 +03:00
..
CHANGELOG.md updated md5 hash handling 2018-09-11 15:49:35 +03:00
cryptmd5.js reformatted md5 2018-09-11 16:03:54 +03:00
LICENSE updated md5 hash handling 2018-09-11 15:49:35 +03:00
package.json updated md5 hash handling 2018-09-11 15:49:35 +03:00
README.md updated md5 hash handling 2018-09-11 15:49:35 +03:00

cryptMD5-for-javascript

JavaScript conversion of crypt_md5() (Original by Poul-Henning Kamp)

This is a conversion of crypt_md5() as it can be found in libcrypt.

A hash created by this function will look like this:

$1$X9U0NCH4$1.cDTvOaCzP41UQ699rOU0
 ^ ^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^
 | |        |
 | |        +- Hashed string
 | |
 | +---------- Salt
 |
 +------------ Identifies this as hash based on MD5

The output is compatible with crypt() (using CRYPT_MD5) in PHP: http://www.php.net/manual/en/function.crypt.php

JavaScript:

var CryptMD5 = require('./cryptmd5.js');

console.log(CryptMD5.cryptMD5('focus123', 'erXgIjX7'));

PHP:

echo crypt('focus123', '$1$erXgIjX7');

Will both return

$1$erXgIjX7$fi/gmab/rku/qc6.ivndo0

(You don't need to specify salt. It will autogenerate a random one if none is present.)