Last active
December 20, 2015 14:59
-
-
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…
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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