Free Photos
WordPress Themes

Encrypt / Decrypt a string with own encryption key

function str_crypt($str, $ky='magicword') { if ($ky=='') return $str; $ky = str_replace(chr(32),'',$ky); if (strlen($ky) < 8) exit('key error'); $kl = strlen($ky)<32?strlen($ky):32; $k = array(); for($i=0;$i<$kl;$i++) { $k[$i]=ord($ky{$i})&0x1F; } $j=0; for($i=0;$i<strlen($str);$i++) { $e=ord($str{$i}); $str{$i}=$e&0xE0?chr($e^$k[$j]):chr($e); $j++;$j=$j==$kl?0:$j; } return $str; }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.