3.4.0 • Published 6 years ago

arc4 v3.4.0

Weekly downloads
366
License
GPL-3.0
Repository
github
Last release
6 years ago

arc4

NPM version Linux Status Windows Status Dependency Status Coveralls

RC4 stream cipher. You can select from ["arc4", "rc4a", "vmpc", "rc4+"] algorithm

Encode/decode with different encodings for *String only, from nodejs doc:

  • 'ascii' - for 7 bit ASCII data only. This encoding method is very fast, and will strip the high bit if set.
  • 'utf8' - Multibyte encoded Unicode characters. Many web pages and other document formats use UTF-8.
  • 'utf16le' - 2 or 4 bytes, little endian encoded Unicode characters. Surrogate pairs (U+10000 to U+10FFFF) are supported.
  • 'ucs2' - Alias of 'utf16le'.
  • 'base64' - Base64 string encoding.
  • 'binary' - A way of encoding raw binary data into strings by using only the first 8 bits of each character. This encoding method is deprecated and should be avoided in favor of Buffer objects where possible. This encoding will be removed in future versions of Node.
  • 'hex' - Encode each byte as two hexadecimal characters.

My original python code

Installation

Install through NPM

npm install arc4

or

git clone git://github.com/hex7c0/arc4.git

API

inside nodejs project

var rc4 = require('arc4');

var cipher = rc4('arc4', 'secret_key');
var d = cipher.encodeString('ciao');
var e = cipher.decodeString(d);

Methods

change your key and reload gKsa (warning)

cipher.change('foo');
cipher.change([30, 31]);
cipher.change(new Buffer('foo'));

encode a plaintext string, you can optionally choose input (defaults to 'utf8') and output (defaults to 'hex') encoding

cipher.encodeString(plaintext [, input_encoding [, output_encoding]]);
cipher.encodeString('string', 'utf8', 'base64');

encode a plaintext array

cipher.encodeArray([49, 50, 51]);

encode a plaintext buffer data

cipher.encodeBuffer(new Buffer('ciao'));

select right function according with plaintext data type. Set input and output encoding only if data is a String

cipher.encode(your_data [, input_encoding [, output_encoding]]);

decode a ciphertext string, you can optionally choose input (defaults to 'hex') and output (defaults to 'utf8') encoding

cipher.decodeString(ciphertext [, input_encoding [, output_encoding]]);
cipher.decodeString('string', 'utf8', 'base64');

decode a ciphertext array

cipher.decodeArray([49,50,51]);

decode a ciphertext buffer data

cipher.decodeBuffer(new Buffer('ciao'));

select right function according with ciphertext data type. Set input and output encoding only if data is a String

cipher.decode(your_data [, input_encoding [, output_encoding]]);

rc4(algorithm, password , lodash)

algorithm

  • algorithm - String Choose between ["arc4", "rc4a", "vmpc", "rc4+"] (default "throw Error")

password

  • password - String | Array | Buffer Your key (default "throw Error")

lodash

  • lodash - Boolean Use lodash library (check benchmark test for right decision) (default "disabled")

Examples

Take a look at my examples

License GPLv3

3.4.0

6 years ago

3.3.8

7 years ago

3.3.7

7 years ago

3.3.6

8 years ago

3.3.5

8 years ago

3.3.4

8 years ago

3.3.3

8 years ago

3.3.2

8 years ago

3.3.1

8 years ago

3.3.0

8 years ago

3.2.1

9 years ago

3.2.0

9 years ago

3.1.3

9 years ago

3.1.2

9 years ago

3.1.1

9 years ago

3.1.0

9 years ago

3.0.8

9 years ago

3.0.7

9 years ago

3.0.6

10 years ago

3.0.5

10 years ago

3.0.4

10 years ago

3.0.3

10 years ago

3.0.2

10 years ago

3.0.1

10 years ago

3.0.0

10 years ago

2.2.5

10 years ago

2.2.4

10 years ago

2.2.3

10 years ago

2.2.2

10 years ago

2.2.1

10 years ago

2.2.0

10 years ago

2.1.4

10 years ago

2.1.3

10 years ago

2.1.2

10 years ago

2.1.1

10 years ago

2.1.0

10 years ago

2.0.0

10 years ago

1.2.0

10 years ago

1.1.1

10 years ago

1.1.0

10 years ago

1.0.0

10 years ago