Skip to content

Instantly share code, notes, and snippets.

@somerongit
Created June 22, 2022 07:56
Show Gist options
  • Save somerongit/5ce124ea07bf2743a7241ed95bbc3e41 to your computer and use it in GitHub Desktop.
Save somerongit/5ce124ea07bf2743a7241ed95bbc3e41 to your computer and use it in GitHub Desktop.
Password Hashing with bcrypt in Type Script
npm i bcrypt@5.0.1 @types/bcrypt@3.0.0
import * as bcrypt from "bcrypt"
function getHash(password: string): string {
const saltRounds = bcrypt.genSaltSync(12)
const hash = bcrypt.hashSync(password,saltRounds)
return hash
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment