crypt.Arc4 Extends
ARC4 streamcipher implementation.

Inheritance

Constructor

goog.crypt.Arc4()

Instance Methods

Public Protected Private
crypt(dataopt_length)
En- or decrypt (same operation for streamciphers like ARC4)
Arguments:
data : Array.<number> | Uint8Array
The data to be xor-ed in place.
opt_length : number=
The number of bytes to crypt.
code »
discard(length)
Discards n bytes of the keystream. These days 1536 is considered a decent amount to drop to get the key state warmed-up enough for secure usage. This is not done in the constructor to preserve efficiency for use cases that do not need this. NOTE: Discard is identical to crypt without actually xoring any data. It's unfortunate to have this code duplicated, but this was done for performance reasons. Alternatives which were attempted: 1. Create a temp array of the correct length and pass it to crypt. This works but needlessly allocates an array. But more importantly this requires choosing an array type (Array or Uint8Array) in discard, and choosing a different type than will be passed to crypt by the client code hurts the javascript engines ability to optimize crypt (7x hit in v8). 2. Make data option in crypt so discard can pass null, this has a huge perf hit for crypt.
Arguments:
length : number
Number of bytes to disregard from the stream.
code »
setKey(keyopt_length)
Initialize the cipher for use with new key.
Arguments:
key : Array.<number>
A byte array containing the key.
opt_length : number=
Indicates # of bytes to take from the key.
code »

Instance Properties

index1_ :
8 bit index pointer into this.state_.
Code »
index2_ :
8 bit index pointer into this.state_.
Code »
state_ :
A permutation of all 256 possible bytes.
Code »

Package crypt

Package Reference