Posted By


gdonald on 09/27/06

Tagged


Statistics


Viewed 657 times
Favorited by 1 user(s)

PHP poor man's crypt


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. function encrypt( $string )
  2. {
  3. $key = 'BXcfTYewQ';
  4. $result = '';
  5. for( $i = 1; $i <= strlen( $string ); $i++ )
  6. {
  7. $char = substr( $string, $i - 1, 1 );
  8. $keychar = substr( $key, ( $i % strlen( $key ) ) - 1, 1 );
  9. $char = chr( ord( $char ) + ord( $keychar ) );
  10. $result .= $char;
  11. }
  12. return $result;
  13. }
  14.  
  15. function decrypt( $string )
  16. {
  17. $key = 'BXcfTYewQ';
  18. $result = '';
  19. for( $i = 1; $i <= strlen( $string ); $i++ )
  20. {
  21. $char = substr( $string, $i - 1, 1 );
  22. $keychar = substr( $key, ( $i % strlen( $key ) ) - 1, 1);
  23. $char = chr( ord( $char ) - ord( $keychar ) );
  24. $result .= $char;
  25. }
  26. return $result;
  27. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.