2 function decrypt_string($str) {
3 $pair = explode(":", $str);
5 if (count($pair) == 2) {
6 @$iv = base64_decode($pair[0]);
7 @$encstr = base64_decode($pair[1]);
10 $key = hash('SHA256', FEED_CRYPT_KEY, true);
12 $str = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $key, $encstr,
13 MCRYPT_MODE_CBC, $iv);
15 if ($str) return rtrim($str);
22 function encrypt_string($str) {
23 $key = hash('SHA256', FEED_CRYPT_KEY, true);
25 $iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128,
26 MCRYPT_MODE_CBC), MCRYPT_RAND);
28 $encstr = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $str,
29 MCRYPT_MODE_CBC, $iv);
31 $iv_base64 = base64_encode($iv);
32 $encstr_base64 = base64_encode($encstr);
34 return "$iv_base64:$encstr_base64";