ericek111

[PCS-SG] Stargate address decoder

Oct 3rd, 2015
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. addr = "ABC";
  2. resx = 0;
  3. acc=1186;
  4. alphabet="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@#";
  5. console.log("Address: " + addr);
  6.  
  7. function comp(iter, pos) {
  8.   if(iter == 0)
  9.     return pos * 37*36;
  10.   if(iter == 1)
  11.     return pos * 37;
  12.   if(iter == 2)
  13.     return pos;
  14. }
  15. for(i = 0; i < addr.length;i++) {
  16.   var index = alphabet.indexOf(addr.charAt(i));
  17.   resx = resx + comp(i, index);
  18.   alphabet = alphabet.replace(alphabet.charAt(index), "");
  19.   console.log("#" + i + ": (" + addr.charAt(i) + "=" + index + ") " + resx);
  20. }
  21. console.log(resx);
Advertisement
Add Comment
Please, Sign In to add comment