0.8.1 • Published 2 months ago

node-ciphers v0.8.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

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
0.8.1

2 months ago

0.8.0

5 months ago

0.7.0

5 months ago

0.6.0

5 months ago

0.5.0

5 months ago

0.4.0

5 months ago

0.3.0

5 months ago

0.2.0

5 months ago

0.1.0

6 months ago