Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function strcode($str, $passw = "", $encode = true) {
- if (!$encode) {
- $str = base64_decode($str);
- }
- $salt = "Dn8*#2n!9j";
- $len = strlen($str);
- $gamma = '';
- $n = $len>100 ? 8 : 2;
- while (strlen($gamma) < $len) {
- $gamma .= substr(pack('H*', sha1($passw.$gamma.$salt)), 0, $n);
- }
- $str = $str ^ $gamma;
- if ($encode) {
- $str = base64_encode($str);
- }
- return $str;
- }
- $txt = "test_string";
- $txt = strcode($txt, 'mypassword', true);
- echo $txt . PHP_EOL;
- $txt = strcode($txt, 'mypassword', false);
- echo $txt;
Advertisement