· 6 years ago · Jul 09, 2019, 07:18 AM
1function player_crypt( $string, $action = 'e' ) {
2 $secret_key = 'otakudesu';
3 $secret_iv = 'google';
4 $output = false;
5 $encrypt_method = "AES-256-CBC";
6 $key = hash( 'sha256', $secret_key );
7 $iv = substr( hash( 'sha256', $secret_iv ), 0, 16 );
8 if( $action == 'e' ) {
9 $output = base64_encode(openssl_encrypt( $string, $encrypt_method, $key, 0, $iv) );
10 }else if( $action == 'd' ){
11 $output = openssl_decrypt( base64_decode($string), $encrypt_method, $key, 0, $iv );
12 }
13 return $output;
14}