Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@aws-crypto/client-node

Package Overview
Dependencies
Maintainers
8
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aws-crypto/client-node

  • 4.0.2
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
168K
decreased by-23.39%
Maintainers
8
Weekly downloads
 
Created

What is @aws-crypto/client-node?

@aws-crypto/client-node is an AWS SDK for JavaScript library that provides client-side encryption and decryption for data. It allows developers to securely encrypt and decrypt data using AWS Key Management Service (KMS) and other cryptographic materials.

What are @aws-crypto/client-node's main functionalities?

Encrypt Data

This feature allows you to encrypt data using a KMS keyring. The code sample demonstrates how to encrypt a simple string using a specified KMS key.

const { encrypt } = require('@aws-crypto/client-node');
const { KmsKeyringNode } = require('@aws-crypto/kms-keyring-node');

const keyring = new KmsKeyringNode({
  generatorKeyId: 'arn:aws:kms:us-west-2:123456789012:key/abcd1234-a123-456a-a12b-a123b4cd56ef',
});

const context = {
  stage: 'demo',
  purpose: 'simple demonstration',
  origin: 'us-west-2',
};

const plaintext = 'Hello, World!';

(async () => {
  const { result } = await encrypt(keyring, plaintext, { encryptionContext: context });
  console.log(result); // Encrypted data
})();

Decrypt Data

This feature allows you to decrypt data that was previously encrypted using a KMS keyring. The code sample demonstrates how to decrypt the encrypted string from the previous example.

const { decrypt } = require('@aws-crypto/client-node');
const { KmsKeyringNode } = require('@aws-crypto/kms-keyring-node');

const keyring = new KmsKeyringNode({
  generatorKeyId: 'arn:aws:kms:us-west-2:123456789012:key/abcd1234-a123-456a-a12b-a123b4cd56ef',
});

const encryptedData = '...'; // Encrypted data from the previous example

(async () => {
  const { plaintext, messageHeader } = await decrypt(keyring, encryptedData);
  console.log(plaintext.toString()); // Decrypted data
})();

Generate Data Key

This feature allows you to generate a data key that can be used for client-side encryption. The code sample demonstrates how to generate a 32-byte data key using a specified KMS key.

const { generateDataKey } = require('@aws-crypto/client-node');
const { KmsKeyringNode } = require('@aws-crypto/kms-keyring-node');

const keyring = new KmsKeyringNode({
  generatorKeyId: 'arn:aws:kms:us-west-2:123456789012:key/abcd1234-a123-456a-a12b-a123b4cd56ef',
});

(async () => {
  const { plaintextKey, ciphertextKey } = await generateDataKey(keyring, { numberOfBytes: 32 });
  console.log(plaintextKey); // Plaintext data key
  console.log(ciphertextKey); // Encrypted data key
})();

Other packages similar to @aws-crypto/client-node

Keywords

FAQs

Package last updated on 21 Oct 2024

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

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc