Skip to content

Commit d7a9bf4

Browse files
author
lucifer
committed
utf8
1 parent d71e803 commit d7a9bf4

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

routes/users.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,14 @@ function encrypt(text) {
1919

2020
const encrypted = Buffer.concat([cipher.update(text), cipher.final()]);
2121

22-
return encrypted.toString("hex");
22+
return encrypted.toString("utf-8");
2323
}
2424

2525
function decrypt(content) {
26-
const decipher = crypto.createDecipheriv(
27-
algorithm,
28-
secret.slice(0, 32),
29-
Buffer.from(iv.toString("hex"), "hex")
30-
);
26+
const decipher = crypto.createDecipheriv(algorithm, secret.slice(0, 32), iv);
3127

3228
const decrpyted = Buffer.concat([
33-
decipher.update(Buffer.from(content, "hex")),
29+
decipher.update(Buffer.from(content, "utf8")),
3430
decipher.final(),
3531
]);
3632

0 commit comments

Comments
 (0)