SHARE
TWEET

sample php encrypt decrypt

selnomeria May 28th, 2020 6 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.        
  2.     public function my_simple_crypt( $string, $secret_key='my_simple_secret_key', $secret_iv = 'my_simple_secret_iv', $action = 'encrypt' ) {
  3.         $encrypt_method = "AES-256-CBC";
  4.         $key = hash( 'sha256', $secret_key );
  5.         $iv = substr( hash( 'sha256', $secret_iv ), 0, 16 );
  6.         return $action == 'encrypt' ? base64_encode( openssl_encrypt( $string, $encrypt_method, $key, 0, $iv ) )  :  openssl_decrypt( base64_decode( $string ), $encrypt_method, $key, 0, $iv );
  7.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top