Skip to content

Crypto utilities for safe password and token handling.

Notifications You must be signed in to change notification settings

slysterous/lazy-crypto

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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));

About

Crypto utilities for safe password and token handling.

Resources

Stars

Watchers

Forks

Packages

No packages published