Last active
October 15, 2017 10:18
-
-
Save kreshikhin/af92121bf2fb5770562b5ff2952fa048 to your computer and use it in GitHub Desktop.
This file contains 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
const gcm = require('node-aes-gcm') | |
const key = new Buffer([0xfe,0xff,0xe9,0x92,0x86,0x65,0x73,0x1c,0x6d,0x6a,0x8f,0x94,0x67,0x30,0x83,0x08]) | |
const iv = new Buffer([0xca,0xfe,0xba,0xbe,0xfa,0xce,0xdb,0xad,0xde,0xca,0xf8,0x88]) | |
const plaintext1 = ` | |
quicksort [] = [] | |
quicksort (x:xs) = quicksort small ++ (x : quicksort large) | |
where small = [y | y <- xs, y <= x] | |
large = [y | y <- xs, y > x] | |
` | |
const plaintext2 = ` | |
quicksort [] = [] | |
quicksort (x:xs) = quicksort small ++ (x : quicksort large) | |
where small = [y | y <- xs, x >= y] | |
large = [y | y <- xs, y > x] | |
` | |
const result1 = gcm.encrypt(key, iv, new Buffer(plaintext1), new Buffer([])) | |
const result2 = gcm.encrypt(key, iv, new Buffer(plaintext2), new Buffer([])) | |
console.log(result1, result2) | |
const ciphertext1 = result1.ciphertext.toString('base64') | |
const ciphertext2 = result2.ciphertext.toString('base64') | |
const chunkSize = 16 | |
for(var i = 0; i < ciphertext1.length; i += chunkSize) { | |
const chunk1 = ciphertext1.slice(i, i+chunkSize) | |
const chunk2 = ciphertext2.slice(i, i+chunkSize) | |
if(chunk1 == chunk2){ | |
console.log(`${i/chunkSize} ${chunk1} => ${chunk2}`) | |
} else { | |
console.log(`${i/chunkSize} ${chunk1} => ${chunk2} changed!!!`) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment