Skip to content

Instantly share code, notes, and snippets.

@theclanks
Created October 10, 2013 21:15
Show Gist options
  • Save theclanks/6925776 to your computer and use it in GitHub Desktop.
Save theclanks/6925776 to your computer and use it in GitHub Desktop.
Criptografia para PHP 5.3
<?
function encrypt($string, $key) {
$encryptionMethod = "AES-256-CBC";
$ivkey = sha1($key);
$iv = substr($ivkey, 0, 16);
return base64_encode(openssl_encrypt($string, $encryptionMethod, $key, 0, $iv));
}
function decrypt($string, $key) {
$string = base64_decode($string);
$encryptionMethod = "AES-256-CBC";
$ivkey = sha1($key);
$iv = substr($ivkey, 0, 16);
return openssl_decrypt($string, $encryptionMethod, $key, 0, $iv);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment