Permalink
Cannot retrieve contributors at this time
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?
FIDO2AppBackend/helpers/utils.js
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
17 lines (14 sloc)
528 Bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
}; |