Posted By

Awesomolocity on 03/24/12


Tagged

awesome encode custom awesomolocity


Versions (?)

KASXencode


 / Published in: JavaScript
 

A custom made encoding method

  1. function KASXencode(x){
  2. var ar_1 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, '-', '.', '\'', '"', '\\', '/', ' ', '(', ')', '$', '%', '*', '@', '&', '^', '?', '!'], ar_2 = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'], len = x.length, split = x.split(''), returnval = '', i, g, num;
  3. for(i = 0; i < split.length; i++){
  4. for(g = 0; g < ar_1.length;g++){
  5. if(ar_1[g]===split[i]){
  6. if((i%2)===1){
  7. num = (len+g)%26;
  8. returnval += ar_2[num];
  9. }
  10. else{
  11. num = (Math.abs(g-len))%26;
  12. returnval += ar_2[num];
  13. }
  14. }
  15. }
  16. for(g = 0; g < ar_2.length;g++){
  17. if(ar_2[g]===split[i]){
  18. if((i%2)===1){
  19. num = (len+g)%26;
  20. returnval += ar_1[num];
  21. }
  22. else{
  23. num = (Math.abs(g-len))%26;
  24. returnval += ar_1[num];
  25. }
  26. }
  27. }
  28. }
  29. return returnval;
  30. }

Report this snippet  

You need to login to post a comment.