1.3.0 • Published 7 years ago

lazy-crypto v1.3.0

Weekly downloads
1
License
MIT
Repository
github
Last release
7 years ago

lazy-crypto

Version npmnpm DownloadsBuild StatusDependencies Known Vulnerabilities NPM

Crypto utilities for safe password and token handling.

Installation

npm install lazy-crypto

Usage

The LazyCrypto contructor takes no arguements.

var LazyCrypto= new require('lazy-crypto');
var lc= new LazyCrypto();

/*generates a token that contains random characters in the range of
0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ and an expiration date.
Can be used for various verification purposes such as email verification*/
var token=lc.generateVerificationToken(4,10);
//token.expires is the expiration date
//token.token is the verification token string

// generates an X length unique salt
var salt=lazyCrypto.generateSalt(20);
//generates a SHA512 hash with the salt provided
var hash=lazyCrypto.generateSha512Hash('password',salt);
//generates both of the above at the same time
var res=lazyCrypto.generateSha512HashAndSalt('password',20);
//boolean result of SHA512 Hash and Salt validation
var valid=lazyCrypto.validateSha512HashAndSalt("password",res.passwordSalt,res.passwordHash));
1.3.0

7 years ago

1.2.0

7 years ago

1.1.0

7 years ago

1.0.0

7 years ago