@pitech-lib/cipher-kit
v1.0.3
Published
An encryption decryption tool-kit
Downloads
34
Readme
🔐 @pitech-lib/cipher-kit
A secure and reusable encryption module for NestJS microservices, using AES-256-GCM. Can be used as a global module or as a direct service provider.
📦 Installation
npm install @pitech-lib/cipher-kitSetup
Option 1: Use as a Global Module (recommended)
Since CipherModule is marked with @Global(), importing it once in your root module makes it available app-wide:
// app.module.ts
import { Module } from '@nestjs/common';
import { CipherModule } from '@pitech-lib/cipher-kit';
@Module({
imports: [CipherModule],
})
export class AppModule {}Option 2: Use as a Provider Manually (optional)
// your.module.ts
import { Module } from '@nestjs/common';
import { CipherService } from '@pitech-lib/cipher-kit';
@Module({
providers: [CipherService],
})
export class YourModule {}and in your service:
@Injectable()
export class TenantService {
constructor(private readonly cipherService: CipherService) {}
handleEncryption() {
const key = this.configService.get<string>('CIPHER_KEY');
const plain = 'sk_live_123abc';
const encrypted = this.cipherService.encrypt(plain, key);
const decrypted = this.cipherService.decrypt(encrypted, key);
}
}