Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion services/security.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ export async function isDisposableEmail(email) {
export async function checkPasswordBreach(password) {
if (!password || password.length < 6) return { breached: false };
try {
const hash = createHash('sha256').update(password).digest('hex').toUpperCase();
const input = String.fromCharCode(...Buffer.from(password, 'utf-8'));
const hash = createHash('sha256').update(input, 'binary').digest('hex').toUpperCase();
const prefix = hash.slice(0, 5);
const suffix = hash.slice(5);
const res = await fetchWithTimeout(`https://api.pwnedpasswords.com/range/${prefix}`, {}, 5000);
Expand Down
Loading