PHP Encrypt Function (selfmade)


SUBMITTED BY: Guest

DATE: July 8, 2013, 6:56 p.m.

FORMAT: PHP

SIZE: 699 Bytes

HITS: 1271

  1. function encode($string)
  2. {
  3. $secString = md5("geheim");
  4. $length = strlen($string);
  5. $pos = rand(0,$length);
  6. $string = base64_encode($string);
  7. $secured = '';
  8. for($i=0;$i<=$length;$i++)
  9. {
  10. if( $i == $pos )
  11. {
  12. $secured .= $secString.$string[$i];
  13. }
  14. else
  15. {
  16. $secured .= $string[$i];
  17. }
  18. }
  19. return $secured;
  20. }
  21. function decode($string)
  22. {
  23. $secString = md5("geheim");
  24. $string = str_replace($secString,"",$string);
  25. $string = base64_decode( $string );
  26. return $string;
  27. }

comments powered by Disqus