Socket
Book a DemoInstallSign in
Socket

@voiceflow/encryption

Package Overview
Dependencies
Maintainers
23
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@voiceflow/encryption

Voiceflow encryption library

latest
npmnpm
Version
0.3.1
Version published
Maintainers
23
Created
Source

encryption

Voiceflow encryption library

Install

yarn add @voiceflow/encryption

Usage

Basic encryption/decryption

import crypto from 'crypto';
import { encryptAes256Gcm, decryptAes256Gcm } from '@voiceflow/encryption';

// create a key
const createAES256Key = () =>
  new Promise<string>((resolve) => {
    crypto.generateKey('aes', { length: 256 }, (err, key) => {
      if (err) throw err;
      resolve(key.export().toString('base64'));
    });
  });
const encryptionKey = await createAES256Key();

// Encrypt data
const plaintext = 'sensitive data';
const encrypted = encryptAes256Gcm(plaintext, encryptionKey);

// Decrypt data
const decrypted = decryptAes256Gcm(encrypted, encryptionKey);
console.log(decrypted); // 'sensitive data'

Using with NestJS

import { Module } from '@nestjs/common';
import { EncryptionModule } from '@voiceflow/encryption';

@Module({
  imports: [
    EncryptionModule.register({
      encryptionKey: 'your-base64-encoded-key',
    }),
  ],
})
export class AppModule {}

Or with async configuration:

import { Module } from '@nestjs/common';
import { ConfigModule, ConfigService } from '@nestjs/config';
import { EncryptionModule } from '@voiceflow/encryption';

@Module({
  imports: [
    ConfigModule.forRoot(),
    EncryptionModule.registerAsync({
      imports: [ConfigModule],
      inject: [ConfigService],
      useFactory: (configService: ConfigService) => ({
        encryptionKey: configService.get('ENCRYPTION_KEY'),
      }),
    }),
  ],
})
export class AppModule {}

Then inject and use the service:

import { Injectable } from '@nestjs/common';
import { EncryptionService } from '@voiceflow/encryption';

@Injectable()
export class YourService {
  constructor(private readonly encryptionService: EncryptionService) {}

  encryptSensitiveData(data: string) {
    return this.encryptionService.encrypt(data);
  }

  decryptSensitiveData(encryptedData) {
    return this.encryptionService.decrypt(encryptedData);
  }
}

FAQs

Package last updated on 29 May 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts