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

@aws-sdk/client-kms

Package Overview
Dependencies
Maintainers
4
Versions
430
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aws-sdk/client-kms

@aws-sdk/client-kms client

  • 1.0.0-alpha.11
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.2M
increased by10.99%
Maintainers
4
Weekly downloads
 
Created

What is @aws-sdk/client-kms?

@aws-sdk/client-kms is an AWS SDK for JavaScript package that allows you to interact with the AWS Key Management Service (KMS). This service enables you to create and manage cryptographic keys and control their use across a wide range of AWS services and in your applications.

What are @aws-sdk/client-kms's main functionalities?

Create a Key

This feature allows you to create a new KMS key. The code sample demonstrates how to create a key with a description, usage type, and origin.

const { KMSClient, CreateKeyCommand } = require('@aws-sdk/client-kms');

const client = new KMSClient({ region: 'us-west-2' });
const command = new CreateKeyCommand({
  Description: 'My test key',
  KeyUsage: 'ENCRYPT_DECRYPT',
  Origin: 'AWS_KMS'
});

client.send(command).then(
  (data) => console.log('Key Created:', data.KeyMetadata.KeyId),
  (error) => console.error('Error:', error)
);

Encrypt Data

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

const { KMSClient, EncryptCommand } = require('@aws-sdk/client-kms');

const client = new KMSClient({ region: 'us-west-2' });
const command = new EncryptCommand({
  KeyId: 'your-key-id',
  Plaintext: Buffer.from('Hello, World!')
});

client.send(command).then(
  (data) => console.log('Encrypted Data:', data.CiphertextBlob.toString('base64')),
  (error) => console.error('Error:', error)
);

Decrypt Data

This feature allows you to decrypt data that was encrypted using a KMS key. The code sample demonstrates how to decrypt a base64-encoded ciphertext.

const { KMSClient, DecryptCommand } = require('@aws-sdk/client-kms');

const client = new KMSClient({ region: 'us-west-2' });
const command = new DecryptCommand({
  CiphertextBlob: Buffer.from('your-encrypted-data', 'base64')
});

client.send(command).then(
  (data) => console.log('Decrypted Data:', data.Plaintext.toString()),
  (error) => console.error('Error:', error)
);

Generate Data Key

This feature allows you to generate a data key that you can use to encrypt data locally. The code sample demonstrates how to generate a 256-bit AES data key.

const { KMSClient, GenerateDataKeyCommand } = require('@aws-sdk/client-kms');

const client = new KMSClient({ region: 'us-west-2' });
const command = new GenerateDataKeyCommand({
  KeyId: 'your-key-id',
  KeySpec: 'AES_256'
});

client.send(command).then(
  (data) => console.log('Data Key:', data.Plaintext.toString('base64')),
  (error) => console.error('Error:', error)
);

Other packages similar to @aws-sdk/client-kms

FAQs

Package last updated on 24 Jan 2020

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