1.0.0-alpha.22 • Published 3 months ago

@guanghechen/cipher v1.0.0-alpha.22

Weekly downloads
-
License
MIT
Repository
github
Last release
3 months ago

Utility functions for cipher contents.

Install

  • npm

    npm install --save @guanghechen/cipher
  • yarn

    yarn add @guanghechen/cipher

Usage

  • AesCipher / AesCipherFactory

    import { AesGcmCipherFactory } from '@guanghechen/cipher'
    
    const cipherFactory = new AesGcmCipherFactory()
    const secret = cipherFactory.createRandomSecret()
    cipherFactory.initFromSecret(secret)
    const cipher = cipherFactory.cipher()
    
    // encrypt
    const originalContent = fs.readFileSync(sourceFilepath)
    const { cryptBytes, authTag } = cipher.encrypt(originalContent)
    
    // decrypt
    const plainBytes: Buffer = cipher.decrypt(cryptBytes, { authTag })

Overview

NameDescription
AesGcmCipherA ICipher implementation with AES-256-GCM algorithm.
AesGcmCipherFactory