Skip to content

Commit cac6673

Browse files
committed
refactor: use bcrypt in hash function
1 parent dd2cb16 commit cac6673

File tree

3 files changed

+223
-7
lines changed

3 files changed

+223
-7
lines changed

package.json

+2
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
"main": "out/node/entry.js",
3737
"devDependencies": {
3838
"@schemastore/package": "^0.0.6",
39+
"@types/bcrypt": "^5.0.0",
3940
"@types/body-parser": "^1.19.0",
4041
"@types/compression": "^1.7.0",
4142
"@types/cookie-parser": "^1.4.2",
@@ -88,6 +89,7 @@
8889
},
8990
"dependencies": {
9091
"@coder/logger": "1.1.16",
92+
"bcrypt": "^5.0.1",
9193
"body-parser": "^1.19.0",
9294
"compression": "^1.7.4",
9395
"cookie-parser": "^1.4.5",

src/node/util.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as cp from "child_process"
22
import * as crypto from "crypto"
3+
import * as bcrypt from "bcrypt"
34
import envPaths from "env-paths"
45
import { promises as fs } from "fs"
56
import * as net from "net"
@@ -116,7 +117,7 @@ export const generatePassword = async (length = 24): Promise<string> => {
116117
}
117118

118119
export const hash = (str: string): string => {
119-
return crypto.createHash("sha256").update(str).digest("hex")
120+
return bcrypt.hashSync(str, 10)
120121
}
121122

122123
const mimeTypes: { [key: string]: string } = {

0 commit comments

Comments
 (0)