Socket
Socket
Sign inDemoInstall

aes-256-gcm

Package Overview
Dependencies
0
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    aes-256-gcm

Simplifies encryption/decryption using the AES 256 GCM algorithm.


Version published
Weekly downloads
481
decreased by-28.21%
Maintainers
1
Install size
5.68 kB
Created
Weekly downloads
 

Readme

Source

AES-256-GCM encryption/decryption shortcuts

A static class that simplifies encryption/decryption using the AES 256 GCM algorithm.

Just use a one-liner to encrypt or decrypt - the IV and tag are handled automatically.

Example

const Aes = require('aes-256-gcm');

// Must be 32 bytes.
const SHARED_SECRET = '12345678901234567890123456789012';

// Encrypt:
let { ciphertext, iv, tag } = Aes.encrypt('hi', SHARED_SECRET);

//   ciphertext: 'VOE='
//   iv: '0K6oPWsBAHLXYtLu5VAvsQ=='
//   tag: 'hCae3Lt5sAK3oNAnUh5emA==' 


// Decrypt:
let cleartext = Aes.decrypt(ciphertext, iv, tag, SHARED_SECRET;

// `cleartext` contains:
// 'hi'

Methods

static encrypt(text, secret)

Encrypts the text using the 256-bit shared key (secret) and returns an object containing three base64-encoded strings:

{ 
  "ciphertext": "(string)", 
  "iv": "(string)", 
  "tag": "(string)"
}

All of those strings must be passed to the end user to successfully decrypt the text.

static decrypt(ciphertext, iv, tag, secret)

Decrypts the ciphertext using the iv and authentication tag tag received from the encryption function, and using the 256-bit shared key (secret).

Returns the decoded string.

Keywords

FAQs

Last updated on 14 Jul 2018

Did you know?

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc