Last active
November 20, 2025 00:29
-
-
Save ghostdevv/f42a5c2053bf5d03cefb6bd95925a8a4 to your computer and use it in GitHub Desktop.
bcrypt util
This file contains hidden or 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
| // Runs with Deno | |
| // deno run --allow-env https://gist.githubusercontent.com/ghostdevv/f42a5c2053bf5d03cefb6bd95925a8a4/raw/bcrypt-util.ts | |
| import { intro, isCancel, log, outro, password, spinner } from 'npm:@clack/prompts@0.11.0'; | |
| import bcrypt from 'npm:bcryptjs@3'; | |
| import pc from 'npm:picocolors@1'; | |
| intro('bcrypt util'); | |
| const pass = await password({ message: 'Enter your password' }); | |
| if (isCancel(pass)) { | |
| log.error('cancelled'); | |
| Deno.exit(0); | |
| } | |
| const s = spinner(); | |
| s.start('generating salt...'); | |
| const salt = await bcrypt.genSalt(10); | |
| s.message('hashing...'); | |
| const hash = await bcrypt.hash(pass, salt); | |
| s.stop('Done!'); | |
| outro(`Hash: ${pc.gray(hash)}\n Base64: ${pc.gray(btoa(hash))}`); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment