When sending get urls, encrypt and decrypt using this method….
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
$dog = "bouncer"; function encryptor($action, $string) { $output = false; $encrypt_method = "AES-256-CBC"; //pls set your unique hashing key $secret_key = '9jju89u8h77$BG6'; $salt = 'hgug78y£tY'; // hash $key = hash('sha256', $secret_key); // iv - encrypt method AES-256-CBC expects 16 bytes - else you will get a warning $iv = substr(hash('sha256', $salt), 0, 16); //do the encyption given text/string/number if( $action == 'encrypt' ) { $output = openssl_encrypt($string, $encrypt_method, $key, 0, $iv); $output = base64_encode($output); } else if( $action == 'decrypt' ){ //decrypt the given text/string/number $output = openssl_decrypt(base64_decode($string), $encrypt_method, $key, 0, $iv); } return $output; } // echo encryptor('encrypt', $dog); echo encryptor('decrypt','V2t5b3d0YzBWOGoralhBWGZHT3lCZz09'); |