Download api/src/service/encrypter.ts from Jessedbrown/warran: direct link, hf CLI and curl.
- Browser
- Download file 381 Bytes
-
https://huggingface.co/Jessedbrown/warran/resolve/main/api/src/service/encrypter.ts
- Command line
-
hf download hf://Jessedbrown/warran/api/src/service/encrypter.ts
-
curl -L -o encrypter.ts https://huggingface.co/Jessedbrown/warran/resolve/main/api/src/service/encrypter.ts
381 Bytes
| import * as bcrypt from 'bcryptjs'; | |
| export class Encrypter { | |
| public async hash(text: string): Promise<string> { | |
| const rounds = 12; | |
| const salt = await bcrypt.genSalt(rounds); | |
| const result = await bcrypt.hash(text, salt); | |
| return result; | |
| } | |
| public async compare(text: string, hash: string): Promise<boolean> { | |
| return await bcrypt.compare(text, hash); | |
| } | |
| } | |