Ofuscar strings


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

Ofuscar strings


Copy this code and paste it in your HTML
  1. function obuscar($str, $key) {
  2. if( ! defined( 'obuscar_hash' ) ) define( 'obuscar_hash', '545487875458715154879664164' );
  3. srand( obuscar_hash );
  4. $salida = '';
  5. $total = strlen($str);
  6. for( $i = -1; ++$i < $total; ){
  7. for( $j = -1; ++$j < ord(substr($key, $i % strlen($key), 1)); ) $toss = rand(0, 255);
  8. $mascara = rand(0, 255);
  9. $salida .= chr( ord( substr( $str, $i, 1) ) ^ $mascara);
  10. }
  11. return $salida;
  12. }
  13.  
  14. echo obuscar('nicolas pardo','Mykey');
  15. echo "<hr>";
  16. echo obuscar('MS¬Š0­9k6g','Mykey');

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.