node package manager

crypt3

Node.js crypt(3) bindings

node-crypt3

crypt(3) for Node.js

Install using npm install crypt3 and use:

Promise version using Q library

var crypt = require('crypt3/q');
crypt('6Xz7sS6fEmnWScMb6Ayf363e5cdqF4Kh', '$1$SrkubyRm$DEQU3KupUxt4yfhbK1HyV/').then(function(value) {
    if( value !== '$1$SrkubyRm$DEQU3KupUxt4yfhbK1HyV/' ) {
        console.error('Access denied!');
        return;
    }
}).fail(function(err) {
    ...
});
var crypt = require('crypt3/async');
crypt('6Xz7sS6fEmnWScMb6Ayf363e5cdqF4Kh', '$1$SrkubyRm$DEQU3KupUxt4yfhbK1HyV/', function(err, value) {
    if(err) {
        ...
        return;
    }
    if( value !== '$1$SrkubyRm$DEQU3KupUxt4yfhbK1HyV/' ) {
        console.error('Access denied!');
        return;
    }
});
var crypt = require('crypt3/sync');
if( crypt('6Xz7sS6fEmnWScMb6Ayf363e5cdqF4Kh', '$1$SrkubyRm$DEQU3KupUxt4yfhbK1HyV/') !== '$1$SrkubyRm$DEQU3KupUxt4yfhbK1HyV/' ) {
    console.error('Access denied!');
    return;
}

Use crypt(key[, salt]):

console.log( crypt('6Xz7sS6fEmnWScMb6Ayf363e5cdqF4Kh') );                                   // Salt generated automatically using default SHA512 
console.log( crypt('6Xz7sS6fEmnWScMb6Ayf363e5cdqF4Kh', crypt.createSalt('md5') ) );         // MD5 salt 
console.log( crypt('6Xz7sS6fEmnWScMb6Ayf363e5cdqF4Kh', crypt.createSalt('blowfish') ) );    // Blowfish salt (only some Linux distros) 
console.log( crypt('6Xz7sS6fEmnWScMb6Ayf363e5cdqF4Kh', crypt.createSalt('sha256') ) );      // SHA-256 
console.log( crypt('6Xz7sS6fEmnWScMb6Ayf363e5cdqF4Kh', crypt.createSalt('sha512') ) );      // SHA-512 

Use crypt.createSalt([type=sha512]) where type is one of md5, blowfish, sha256 or sha512 (default).

You can buy commercial support from Sendanor.