arc4

Create an (alleged) RC4 stream cipher.

Disclaimer: The RC4 algorithm does not meet the basic criteria for an encryption algorithm. RC4 output is distinguishable from random output, and the algorithm has numerous security vulnerabilities. You have been warned.

Usage

var arc4 = require( '@stdlib/crypto/arc4' );

arc4( key )

Returns an (alleged) RC4 stream cipher.

var cipher = arc4( 'pwd12' );

cipher( text )

Applies an (alleged) RC4 cipher to provided text.

var cipher = arc4( 'pwd12' );

var out = cipher( 'beep boop bop' );
// returns 'C¬~û˒bIuåÓ'

Examples

var arc4 = require( '@stdlib/crypto/arc4' );

var text = 'beep boop bop';

// Create an encryption cipher:
var encrypt = arc4( 'pwd12' );

// Encrypt some plain text:
var out = encrypt( text );
// returns 'C¬~û˒bIuåÓ'

// Create a decryption cipher initialized with the same key (and thus initial state):
var decrypt = arc4( 'pwd12' );

// Decrypt the encrypted string:
var str = decrypt( out );
// returns 'beep boop bop'

CLI

Usage

Usage: arc4 [options] --key=<string> [<text>]

Options:

  -h,    --help                Print this message.
  -V,    --version             Print the package version.
         --key key             Cipher key.

Examples

Provide text as a command-line argument:

$ arc4 --key pwd12 'beep boop bop' 
...

Use as a standard stream:

$ arc4 --key pwd12 'beep boop bop' | arc4 --key pwd12
beep boop bop

References

  • Schneier, Bruce. 1996. Applied Cryptography: Protocols, Algorithms, and Source Code in C. 2nd ed. New York: Wiley.
  • RFC 6229 (and references therein).