Added the decryption util
This commit is contained in:
parent
3ce7b1941d
commit
2777aea903
8
src/utils/decryption.ts
Normal file
8
src/utils/decryption.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
import fieldEncryption from "mongoose-field-encryption";
|
||||||
|
import crypto from "crypto";
|
||||||
|
|
||||||
|
const createHash = () => crypto.createHash("sha256").update(process.env.ENC_KEY || "").digest("hex").substring(0, 32);
|
||||||
|
|
||||||
|
export const encryptClearField = (text: string) => fieldEncryption.encrypt(text, createHash(), () => process.env.SIG_KEY);
|
||||||
|
|
||||||
|
export const decryptField = (encrypted: string) => fieldEncryption.decrypt(encrypted, createHash());
|
Loading…
x
Reference in New Issue
Block a user