Last active
December 31, 2015 10:39
-
-
Save jeffreyroberts/7974872 to your computer and use it in GitHub Desktop.
aes encrypt and decrypt
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
<?php | |
function aes_decrypt($code, $key, $iv) { | |
$mode = MCRYPT_MODE_CBC; | |
$enc = MCRYPT_RIJNDAEL_128; | |
return mcrypt_decrypt($enc, $key, $code, $mode, $iv); | |
} | |
function aes_encrypt($code, $key, $iv) { | |
$mode = MCRYPT_MODE_CBC; | |
$enc = MCRYPT_RIJNDAEL_128; | |
return mcrypt_encrypt($enc, $key, $code, $mode, $iv); | |
} | |
$encryptable = 'asdfasdfasdf'; | |
$iv = "000000000000000" . dechex(1); | |
$key = '238EF4477A3ADD32385C584EED6A4B8B'; | |
$encrypted = aes_encrypt($encryptable, $key, $iv); | |
//PROVA DELLE FUNZIONI | |
$test2 = aes_decrypt($encrypted, $key, $iv); | |
echo $test2; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment