Skip to content

Documentation / @tenancy-node/db / Encrypter

Class: Encrypter ​

Defined in: db/src/crypto/encrypter.ts:39

Cifrado AES-256-GCM con rotación de llaves. Cada valor guarda el id de la llave con la que se cifró (tn1.<kid>.<iv>.<tag>.<datos>), así una llave nueva puede convivir con las anteriores.

Constructors ​

Constructor ​

new Encrypter(key?, previousKeys?): Encrypter

Defined in: db/src/crypto/encrypter.ts:43

Parameters ​

key? ​

string

previousKeys? ​

readonly string[] = []

Returns ​

Encrypter

Accessors ​

currentKeyId ​

Get Signature ​

get currentKeyId(): string | undefined

Defined in: db/src/crypto/encrypter.ts:54

Returns ​

string | undefined


hasKey ​

Get Signature ​

get hasKey(): boolean

Defined in: db/src/crypto/encrypter.ts:50

Returns ​

boolean

Methods ​

decrypt() ​

decrypt(value): string

Defined in: db/src/crypto/encrypter.ts:73

Parameters ​

value ​

string

Returns ​

string


encrypt() ​

encrypt(plain): string

Defined in: db/src/crypto/encrypter.ts:58

Parameters ​

plain ​

string

Returns ​

string


needsRotation() ​

needsRotation(value): boolean

Defined in: db/src/crypto/encrypter.ts:92

true si el valor fue cifrado con una llave que no es la actual.

Parameters ​

value ​

string

Returns ​

boolean


rotate() ​

rotate(value): string

Defined in: db/src/crypto/encrypter.ts:97

Vuelve a cifrar el valor con la llave actual.

Parameters ​

value ​

string

Returns ​

string

Publicado bajo la licencia MIT.