goog.crypt.Arc4
Instance Methods
expand_more
this.crypt( data, opt_length ) → void
void
expand_more
this.discard( length ) → void
void
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:
- 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).
- Make data option in crypt so discard can pass null, this has a huge perf hit for crypt.
Parameters |
|
---|
expand_more
this.setKey( key, opt_length ) → void
void