0.2.0 • Published 12 months ago

crypt-unix v0.2.0

Weekly downloads
-
License
BSD-3-Clause
Repository
github
Last release
12 months ago

crypt-unix

A pure-JavaScript library to provide UNIX/Linux crypt(1). It uses Node's crypto for the cryptography. This tool allows you to generate and verify passwords as used in UNIX's/Linux's /etc/shadow file, or other tools that generate the same format.

IDSchemeSupported
DES:x:
_BSDi:x:
1MD5
2, 2a, 2b, 2x, 2ybcrypt:x:
3NTHASH:x:
5SHA-256
6SHA-512
7scrypt:x:

The unsupported formats will be added in future releases - v1.0.0 should have all of these formats available.

Export and Example

This file just has the default export: crypt(string password, string salt): boolean.

import crypt from 'crypt-unix';

const hashedPassword = "$6$saltstring$svn8UoSVapNtMuq1ukKS4tPQd8iKwSMHWjl/O817G3uBnIFNjnQJuesI68u4OTLiBFdcbYEdFCoEOfaS35inz1";

function verifyPassword(string enteredPassword): boolean {
  return crypt(enteredPassword, hashedPassword) === hashedPassword;
}
0.2.0

12 months ago

0.1.0

12 months ago