mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-06 09:26:47 +00:00
optimised import
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import crypto from "crypto"; // added types from @types/node
|
import { createHash } from "crypto"; // added types from @types/node
|
||||||
|
|
||||||
export const checkIsPasswordBreached = async (password: string) => {
|
export const checkIsPasswordBreached = async (password: string) => {
|
||||||
// see API details here: https://haveibeenpwned.com/API/v3#SearchingPwnedPasswordsByRange
|
// see API details here: https://haveibeenpwned.com/API/v3#SearchingPwnedPasswordsByRange
|
||||||
@@ -14,7 +14,7 @@ export const checkIsPasswordBreached = async (password: string) => {
|
|||||||
try {
|
try {
|
||||||
const textEncoder = new TextEncoder();
|
const textEncoder = new TextEncoder();
|
||||||
const encodedPwd = textEncoder.encode(password);
|
const encodedPwd = textEncoder.encode(password);
|
||||||
const hash = crypto.createHash("sha1").update(encodedPwd).digest();
|
const hash = createHash("sha1").update(encodedPwd).digest();
|
||||||
|
|
||||||
const hashedPwd = Array.from(new Uint8Array(hash))
|
const hashedPwd = Array.from(new Uint8Array(hash))
|
||||||
.map((byte) => byte.toString(16).padStart(2, "0"))
|
.map((byte) => byte.toString(16).padStart(2, "0"))
|
||||||
|
|||||||
Reference in New Issue
Block a user