Thomas Woelk wrote:

>Hello,
>
>is anywhere a code snippet available for scramble/unscramble a clipboard
>entry with ROT-13?
>

Hi Thomas,

Below are the encoder/decoder functions I've extracted from the Rot13 
Encoder/Decoder Firefox extension, I can send you the whole JS file if 
you'd like.

The extension author credits http://tools.geht.net/rot13.html for the 
original code though, and it's publicly available at that URL (view the 
page source code) so check there too.

That should give you a starting point, let me know if you get stuck,

Cheers
Karen


 rot13EncoderInit: function() {
       var map = new Array();
       var s   = "abcdefghijklmnopqrstuvwxyz";
       for (i=0; i<s.length; i++)
     map[s.charAt(i)]= s.charAt((i+13)%26);
       for (i=0; i<s.length; i++)
     map[s.charAt(i).toUpperCase()]= s.charAt((i+13)%26).toUpperCase();
       return map;
   },
  decode: function (text) {
      // rot13 decode function taken from Valentin Hilbig
      // origin: 2000-01-08 [EMAIL PROTECTED] http://tools.geht.net/rot13.html
      var src = new String(text);
      var rot13map;
      var s;
      var i;
      rot13map=rot13.rot13EncoderInit();
      s = "";
      for (i=0; i<src.length; i++) {
      var b = src.charAt(i);
      s+= (b>='A' && b<='Z' || b>='a' && b<='z' ? rot13map[b] : b);
      }
      return s;
  },






Attention: PowerPro's Web site has moved: http://www.ppro.org 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/power-pro/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to