Crypto

An implementation of cryptographic features such as data encoding, RSA key generation, and authentication tokens.

Available:

  • Crypto

  • Fake

Methods:

GenerateKeys: Generates a pair of RSA keys and exports them both in PEM format, converts the public key to JWK, and saves all of them to specific files.

this.cryptoProvider.generateKeys();

GenerateRefreshToken: Generates a signed refreshToken from a unique identifier.

const id = uuid();

const data = this.cryptoProvider.generateRefreshToken(id);

GenerateJwtToken: Generates a default jsonWebToken.

const id = uuid();

const data = this.cryptoProvider.generateJwtToken(
  { email: 'emai@mail.com' },
  { subject: id },
);

Encrypt: Encrypts a piece of data passed by parameter.

const { content, iv } = this.cryptoProvider.encrypt('12345');

Decrypt: Decrypts an encrypted content from the IV.

const data = this.cryptoProvider.decrypt({ content, iv });

Last updated