Created
April 5, 2011 04:17
-
-
Save fabiomcosta/903024 to your computer and use it in GitHub Desktop.
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
var crypto = require("crypto"); | |
var repeat = function(str, times){ | |
var _str = str; | |
while(--times){ | |
str += _str; | |
} | |
return str; | |
}; | |
var cipher = crypto.createCipher("aes-128-ecb", repeat("1", 16)); | |
// changing to "ascii" or "binary" will give the same result | |
console.log(cipher.update(repeat("2", 16), "utf8", "base64")); // prints K5GLLZeXr3ufthAEFTTe |
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
import base64 | |
from Crypto.Cipher import AES | |
cypher = AES.new("1" * 16) | |
print base64.b64encode(cypher.encrypt("2" * 16)) # prints MoiphN0G/1jpOWCx3sUPHg== |
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
require 'openssl' | |
require 'base64' | |
c = OpenSSL::Cipher::Cipher.new("aes-128-ecb") | |
c.encrypt | |
c.key = "1" * 16 | |
e = c.update("2" * 16) | |
e = Base64.encode64(e) | |
puts e # prints MoiphN0G/1jpOWCx3sUPHg== |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment