Advertisement
Antstrain

Rot13 function

Sep 13th, 2013
314
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function rot13(str) {
  2.     var nycunorg={
  3. a:'n',b:'o',c:'p',d:'q',e:'r',f:'s',g:'t',h:'u',i:'v',j:'w',k:'x',l:'y',m:'z',n:'a',o:'b',p:'c',q:'d',r:'e',s:'f',t:'g',u:'h',v:'i',w:'j',x:'k',y:'l',z:'m'
  4.     }
  5.     var i=0;
  6.     var result=""
  7.     while (i<str.length) {
  8.         var nextchar=str.charAt(i)
  9.         n=nycunorg[nextchar]
  10.         if (n===undefined) {
  11.             n=nycunorg[nextchar.toLowerCase()]
  12.         if (n===undefined) {
  13.             n=nextchar;
  14.             }
  15.             else
  16.             {
  17.             n=n.toUpperCase();
  18.             }
  19.         }
  20.         result=result.concat(n);
  21.         i=i+1;
  22.     }
  23.     return result
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement