Skip to content

Instantly share code, notes, and snippets.

@yuiseki
Last active December 18, 2015 10:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yuiseki/5772107 to your computer and use it in GitHub Desktop.
Save yuiseki/5772107 to your computer and use it in GitHub Desktop.
# node v0.10.10
crypto = require "crypto"
secretKey = [
0xff, 0x03, 0x44, 0x89, 0xd6, 0xf8, 0x98, 0x21,
0x1f, 0xad, 0xaa, 0xda, 0x39, 0x9d, 0x3f, 0x8e,
0xbc, 0xd5, 0xa1, 0x00, 0xe1, 0x36, 0xfa, 0xcc,
0xe7, 0x48, 0x0a, 0x0e, 0x44, 0x1c, 0xf6, 0xaf,
]
secretKeyBuf = new Buffer(secretKey)
iv = ""
plain = "ニンジャ、殺すべし!"
plainEnc = "utf8"
cipher1 = crypto.createCipheriv("rc4", secretKeyBuf, iv)
crypted1 = cipher1.update(plain, plainEnc).toString("base64")
console.log crypted1
cipher2 = crypto.createCipheriv("rc4", secretKeyBuf, iv)
crypted2 = cipher2.update plain, plainEnc, "base64"
console.log crypted2
console.log crypted1 == crypted2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment