Skip to content

Instantly share code, notes, and snippets.

@martijndwars
Last active December 20, 2015 14:59
Show Gist options
  • Save martijndwars/6151326 to your computer and use it in GitHub Desktop.
Save martijndwars/6151326 to your computer and use it in GitHub Desktop.
Nodes crypto module provides a rc4 cipher, but it lacks the ability to drop the first bytes from the keystream. This gist simply encrypts as many bytes as you want to drop, effectively causing those bytes from the keystream to get dropped. For full implementations of RC4Drop, please see: - https://github.com/gwjjeff/cryptojs - https://gist.githu…
crypto = require 'crypto'
class RC4
constructor: (@key, drop) ->
@cipher = crypto.createCipher 'rc4', key
if drop > 0
this.cipher.update new Buffer drop
encrypt: (data) ->
@cipher.update data
module.exports = RC4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment