Skip to content

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

License

Notifications You must be signed in to change notification settings

execmd/crypto-rc4

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published