4.0.0 • Published 3 years ago

@frontendmonster/crypto v4.0.0

Weekly downloads
11
License
MIT
Repository
github
Last release
3 years ago

crypto

Useful encryption and jwt utils

Bcrypt

import { hash, hashSync, compare } from '@frontendmonster/crypto';

const passwordHash = await hash(password, saltLen); // hash password with specific salt and returns Promise<string>
const passwordHashSync = await hashSync(password, saltLen); // hash password with specific salt and returns hash
const isValid = await compare(userPassword, hashedPassword); // compare hashed passwords

Id

import { randomId, randomHex, randomNumber } from '@frontendmonster/crypto';

const id = randomId(16); // create 16-len uid
const hex = randomHex(16); // create 16-len uid
const HEX = randomHex(16, { casing: 'uppercase' }); // create 16-len uppercase hex string
const numbers = randomNumber(16); // create 16-len number string

JWT

import { decode, sign, verify } from '@frontendmonster/crypto';
const jwt = sign(payload, secret, option); // sign json web token
const isValid = verify(jwt, token); // verify json web token
const payload = decode(jwt); // decode json web token
4.0.0

3 years ago

3.0.3

3 years ago

3.0.2

3 years ago

3.0.1

3 years ago

3.0.0

3 years ago

2.1.0

5 years ago

2.0.1

5 years ago

2.0.0

5 years ago