PHP/Javascript Problem

A

Anonymous

Guest
here is some func in PHP posted
Code:
 joh at n dot liesen dot se
26-Nov-2004 10:05
It's also possible to rot13 a string without using a lookup table.

<?php
function rot13($s)
{
   $rot13  = "";
  
   for ($i = 0; $i < strlen($s); ++$i)
   {
     $char = ord($s{$i});
     $cap = $char & 32;
    
     $char &= ~$cap;
     $char = (($char >= ord('A')) && ($char <= ord('z'))) ? (($char - ord('A') + 13) % 26 + ord('A')) : $char;
     $char |= $cap;
    
     $rot13 .= chr($char);
   }
  
   return $rot13;
}
?>

You can definately do the above in JavaScript
I hope you have the Javascript 1.3 reference Manual, Because Devedge.netscape.com is down since more than a month now... Mozilla guys seem to recover it.
 
Back
Top