Encrypt archives at rest
This commit is contained in:
parent
7562a886e1
commit
a017aa7bfe
3 changed files with 47 additions and 1 deletions
21
backend/src/data/encryptedTextTransformer.ts
Normal file
21
backend/src/data/encryptedTextTransformer.ts
Normal file
|
@ -0,0 +1,21 @@
|
|||
import { decrypt, encrypt } from "../utils/crypt";
|
||||
import { ValueTransformer } from "typeorm";
|
||||
|
||||
interface EncryptedTextTransformer extends ValueTransformer {
|
||||
from(dbValue: any): string;
|
||||
to(entityValue: string): any;
|
||||
}
|
||||
|
||||
export function createEncryptedTextTransformer(): EncryptedTextTransformer {
|
||||
return {
|
||||
// Database -> Entity
|
||||
from(dbValue) {
|
||||
return decrypt(dbValue);
|
||||
},
|
||||
|
||||
// Entity -> Database
|
||||
to(entityValue) {
|
||||
return encrypt(entityValue);
|
||||
},
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue