Skip to content

Instantly share code, notes, and snippets.

@ghostdevv
Last active November 20, 2025 00:29
Show Gist options
  • Select an option

  • Save ghostdevv/f42a5c2053bf5d03cefb6bd95925a8a4 to your computer and use it in GitHub Desktop.

Select an option

Save ghostdevv/f42a5c2053bf5d03cefb6bd95925a8a4 to your computer and use it in GitHub Desktop.
bcrypt util
// 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