1.0.0 • Published 9 years ago

crypto-rc4 v1.0.0

Weekly downloads
6
License
-
Repository
github
Last release
9 years ago

crypto-rc4 Build Status

Javascript library for simple crypting with RC4 key sharing data over internet

Example

var fs        = require('fs'),
    cryptoRC4 = require('crypto-rc4');

var crypto = new cryptoRC4(
    fs.readFileSync('private.pem', {encoding: 'UTF-8'}),
    fs.readFileSync('public.pem'), {encoding: 'UTF-8'})
);

var message = 'SOME SENSITIVE DATA';

var encrypted = crypto.encrypt(message);
console.log(encrypted);
// { data: [Base64 of encrypted data], key: [Base64 of encryption key]}

var sign = crypto.sign(message);
console.log(sign);
// [Base64 of signature]

var decrypted = crypto.decrypt(encrypted.data, encrypted.key);
console.log(decrypted);
// SOME SENSITIVE DATA
console.log(crypto.verify(decrypted, sign));
// true

Installing

npm install crypto-rc4

Requires nodejs >= 0.10.x or io.js >= 1.x

Testing

npm test

Usage

var cryptoRC4 = require('crypto-rc4');
var crypto = new cryptoRC4(privateKey, publicKey[, rc4KeyLen]);

This library uses node-rsa module, which is used to operate with RSA keys, so

  • privateKey - {string|buffer}
  • publicKey - {string|buffer}
  • rc4KeyLen - {int} optional, Define how long will be encryption key in bytes. If not defined it sets to 10.
var crypto.encrypt(cleartext);
  • cleartext - {string} The string which we want to encrypt