Use this if you want to use it safely:
<input type='hidden' name='username' value='<?php echo encode("Please Encode Me!","This is a key"); ?>' />
which will result in:
<input type='hidden' name='username' value='p3e4e4241674d2r4m4i5o464a4f2p3k5c2' />
and in the script modification you will need to use:
<?php $username = decode("p3e4e4241674d2r4m4i5o464a4f2p3k5c2","This is a key"); ?>
Below you have the PHP functions for ENCODE / DECODE:
<?php function encode($string,$key) { $key = sha1($key); $strLen = strlen($string); $keyLen = strlen($key); for ($i = 0; $i < $strLen; $i++) { $ordStr = ord(substr($string,$i,1)); if ($j == $keyLen) { $j = 0; } $ordKey = ord(substr($key,$j,1)); $j++; $hash .= strrev(base_convert(dechex($ordStr + $ordKey),16,36)); } return $hash; } function decode($string,$key) { $key = sha1($key); $strLen = strlen($string); $keyLen = strlen($key); for ($i = 0; $i < $strLen; $i+=2) { $ordStr = hexdec(base_convert(strrev(substr($string,$i,2)),36,16)); if ($j == $keyLen) { $j = 0; } $ordKey = ord(substr($key,$j,1)); $j++; $hash .= chr($ordStr - $ordKey); } return $hash; } ?>
source share