CasperSecurity
<?php
// function amebi_crypt( $string, $action) {
// $secret_key = 'bHNhZ2FyaWth';
// $secret_iv = 'YWNoaW50eWFu';
//
// $output = false;
// $encrypt_method = "AES-256-CBC";
// $key = hash( 'sha256', $secret_key );
// $iv = substr( hash( 'sha256', $secret_iv ), 0, 16 );
//
// if( $action == 'e' ) {
// $output = base64_encode( openssl_encrypt( $string, $encrypt_method, $key, 0, $iv ) );
// }
// else if( $action == 'd' ){
// $output = openssl_decrypt( base64_decode( $string ), $encrypt_method, $key, 0, $iv );
// }
//
// return $output;
// }
//?>
<?php
function amebi_crypt($string, $action) {
if (!is_string($action)) {
$action = strtolower($action);
}
$action = trim(strtolower($action));
$secret_key = 'bHNhZ2FyaWth';
$secret_iv = 'YWNoaW50eWFu';
$encrypt_method = "AES-256-CBC";
$key = hash('sha256', $secret_key);
$iv = substr(hash('sha256', $secret_iv), 0, 16);
if ($action === 'e') {
return base64_encode(openssl_encrypt($string, $encrypt_method, $key, 0, $iv));
}
else if ($action === 'd') {
return openssl_decrypt(base64_decode($string), $encrypt_method, $key, 0, $iv);
}
return false;
}
?>