JSPM

  • Created
  • Published
  • Downloads 64
  • Score
    100M100P100Q67558F
  • License MIT

Easy-to-use cipher classes such as AES, DES, etc.

Package Exports

  • node-ciphers
  • node-ciphers/dist/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (node-ciphers) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

node-ciphers

Easy-to-use cipher classes such as AES, DES, etc.

Documentation will be improved in future releases.

There is an example of aes-cbc below, you can also refer to the code in the test to use the package.

Installation

npm i node-ciphers		# npm
pnpm add node-ciphers	# pnpm

Examples

AES-CBC

import { AESCipher } from 'node-ciphers';

const cipher = AESCipher.CBC('key');

// Encrypt
const encryptResult = cipher.encrypt('your data');
console.log(encryptResult);
/**
 * {
 * 		data: 'encryptedText',
 * 		iv: 'iv string'
 * }
 */

// Decrypt
console.log(cipher.decrypt(encryptResult.data, encryptResult.iv));
// 'your data'

If an encryption/decryption error occurs, undefined will be returned.

If the incoming key is a string, it will be converted to a buffer using utf8 by default.

Depending on the length of the key, AES-128, AES-192 or AES-256 mode will be used to create the cipher instance.

  • 16 bytes for AES-128
  • 24 bytes for AES-192
  • 32 bytes for AES-256