Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
import base64url from 'base64url'
import crypto from "crypto";
import bcrypt from "bcrypt";
export const randomBase64URLBuffer = (length = 32) => {
const bytes = crypto.randomBytes(length)
const base64 = base64url(bytes)
return {base64: base64, bytes: bytes}
};
export const toBase64 = (bytes) => base64url(bytes)
export const fromBase64 = (base64) => base64url.decode(base64)
export const verifyPassword = function (user, password) {
const isMatch = bcrypt.compareSync(password, user.password);
return isMatch;
};