Created
February 6, 2012 20:06
-
-
Save joslynesser/1754488 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
require 'openssl' | |
require 'base64' | |
key = '7fc4d85e2e4193b8' | |
crypted_text = Base64.decode64(ARGV[0]) | |
cipher = OpenSSL::Cipher::Cipher.new("aes-128-cbc") | |
cipher.decrypt | |
cipher.key = key | |
decrypted = "" | |
decrypted << cipher.update(crypted_text) | |
decrypted << cipher.final |
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
<?php | |
$key = "7fc4d85e2e4193b8"; | |
$text = "Read me! This is a fun message..."; | |
$iv = "OpenSSL for Ruby"; | |
// Add required padding | |
$pad = 16 - (strlen($crypttext) % 16); | |
$text = $text . str_repeat(chr($pad), $pad); | |
// XOR first block due to ruby's openssl performing this when using the static IV | |
for ($i = 0; $i < 16; $i++) { | |
$text[$i] = $text[$i] ^ $iv[$i]; | |
} | |
$encrypted = base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $text, MCRYPT_MODE_CBC, $iv)); | |
print $encrypted ."\n"; | |
?> |
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' | |
key = '7fc4d85e2e4193b8' | |
crypted_text = Base64.decode64(ARGV[0]) | |
iv = "Random IV Winner" | |
cipher = OpenSSL::Cipher::Cipher.new("aes-128-cbc") | |
cipher.decrypt | |
cipher.key = key | |
cipher.iv = "OpenSSL NOT Ruby" | |
decrypted = "" | |
decrypted << cipher.update(crypted_text) | |
decrypted << cipher.final |
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
<?php | |
$key = "7fc4d85e2e4193b8"; | |
$text = "Read me! This is a fun message..."; | |
$iv = "Random IV Winner"; | |
// Add required padding | |
$pad = 16 - (strlen($crypttext) % 16); | |
$text = $text . str_repeat(chr($pad), $pad); | |
$encrypted = base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $text, MCRYPT_MODE_CBC, $iv)); | |
print $encrypted ."\n"; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment