· 7 years ago · Sep 02, 2018, 10:16 AM
1public function cryption($string, $action = 'e')
2{
3 $secret_key = 'secret-key';
4 $secret_iv = 'secret_iv';
5
6 $output = false;
7 $encrypt_method = "AES-256-CBC";
8 $key = hash( 'sha256', $secret_key );
9 $iv = substr( hash( 'sha256', $secret_iv ), 0, 16 );
10
11 if( $action == 'e' ){
12 $output = openssl_encrypt( $string, $encrypt_method, $key, 0, $iv );
13 }else if( $action == 'd' ){
14 $output = openssl_decrypt( $string, $encrypt_method, $key, 0, $iv );
15 }
16 return $output;
17}
18
19yTJbtH7mIJjhY+SatnTxY5i2jt/qUW+nZgmGBeBgZEzpy2GMSBQgDjKeyjxGOdJd