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

aes-js

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

aes-js

A pure JavaScript implementation of the AES block cipher and all common modes of operation.

  • 4.0.0-beta.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
687K
decreased by-54.53%
Maintainers
1
Weekly downloads
 
Created

What is aes-js?

The aes-js npm package is a pure JavaScript implementation of the AES block cipher algorithm and all common modes of operation (CBC, CFB, CTR, ECB, and OFB).

What are aes-js's main functionalities?

Encryption and Decryption

This feature allows you to encrypt and decrypt text using AES. The code sample shows how to convert text to bytes, encrypt it, and then decrypt it back to the original text.

{"encryption":"var AES = require('aes-js'); var key = AES.utils.utf8.toBytes('your-key-here'); var text = 'Text to encrypt'; var textBytes = AES.utils.utf8.toBytes(text); var aesCtr = new AES.ModeOfOperation.ctr(key, new AES.Counter(5)); var encryptedBytes = aesCtr.encrypt(textBytes); var encryptedHex = AES.utils.hex.fromBytes(encryptedBytes);","decryption":"var encryptedBytes = AES.utils.hex.toBytes(encryptedHex); var aesCtr = new AES.ModeOfOperation.ctr(key, new AES.Counter(5)); var decryptedBytes = aesCtr.decrypt(encryptedBytes); var decryptedText = AES.utils.utf8.fromBytes(decryptedBytes);"}

Conversion Utilities

aes-js provides utility functions to convert text to bytes and vice versa, as well as to convert bytes to hex strings and vice versa. This is useful for handling the data before and after encryption/decryption.

{"conversion":"var AES = require('aes-js'); var text = 'Text to convert'; var textBytes = AES.utils.utf8.toBytes(text); var textHex = AES.utils.hex.fromBytes(textBytes); var bytes = AES.utils.hex.toBytes(textHex); var textFromBytes = AES.utils.utf8.fromBytes(bytes);"}

Block Cipher Modes of Operation

aes-js supports various modes of operation for the AES algorithm, including CBC (Cipher Block Chaining), CTR (Counter), and others. The code sample demonstrates how to use CBC and CTR modes for encryption.

{"cbc":"var AES = require('aes-js'); var key = AES.utils.utf8.toBytes('your-key-here'); var iv = AES.utils.utf8.toBytes('initialization-vector'); var text = 'Text to encrypt'; var textBytes = AES.utils.utf8.toBytes(text); var aesCbc = new AES.ModeOfOperation.cbc(key, iv); var encryptedBytes = aesCbc.encrypt(textBytes);","ctr":"var aesCtr = new AES.ModeOfOperation.ctr(key, new AES.Counter(5)); var encryptedBytes = aesCtr.encrypt(textBytes);"}

Other packages similar to aes-js

Keywords

FAQs

Package last updated on 23 Mar 2022

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