Guest User

Untitled

a guest
Oct 22nd, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. encode : function (input) {
  2. var output = "";
  3. var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
  4. var i = 0;
  5.  
  6. input = Base64._utf8_encode(input);
  7.  
  8. while (i < input.length) {
  9.  
  10. chr1 = input.charCodeAt(i++);
  11. chr2 = input.charCodeAt(i++);
  12. chr3 = input.charCodeAt(i++);
  13.  
  14. enc1 = chr1 >> 2;
  15. enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
  16. enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
  17. enc4 = chr3 & 63;
  18.  
  19. if (isNaN(chr2)) {
  20. enc3 = enc4 = 64;
  21. } else if (isNaN(chr3)) {
  22. enc4 = 64;
  23. }
  24.  
  25. output = output +
  26. this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) +
  27. this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4);
  28.  
  29. }
  30.  
  31. return output;
  32. }
Add Comment
Please, Sign In to add comment