Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function encode_ascii85(a) {
  2.     var b, c, d, e, f, g, h, i, j, k;
  3.     for (!/[^\\x00-\\xFF]/.test(a), b = "\\x00\\x00\\x00\\x00".slice(a.length % 4 || 4), a += b,
  4.      c = [], d = 0, e = a.length; e > d; d += 4) f = (a.charCodeAt(d) << 24) + (a.charCodeAt(d + 1) << 16) + (a.charCodeAt(d + 2) << 8) + a.charCodeAt(d + 3),
  5.     0 !== f ? (k = f % 85, f = (f - k) / 85, j = f % 85, f = (f - j) / 85, i = f % 85,
  6.            f = (f - i) / 85, h = f % 85, f = (f - h) / 85, g = f % 85, c.push(g + 33, h + 33, i + 33, j + 33, k + 33)) :c.push(122);
  7.     return function(a, b) {
  8.     for (var c = b; c > 0; c--) a.pop();
  9.     }(c, b.length), "<~" + String.fromCharCode.apply(String, c) + "~>";
  10. }
  11. function decode_ascii85(a) {
  12.     var c, d, e, f, g, h = String, l = "length", w = 255, x = "charCodeAt", y = "slice", z = "replace";
  13.     for ("<~" === a[y](0, 2) && "~>" === a[y](-2), a = a[y](2, -2)[z](/\s/g, "")[z]("z", "!!!!!"),
  14.      c = "uuuuu"[y](a[l] % 5 || 5), a += c, e = [], f = 0, g = a[l]; g > f; f += 5) d = 52200625 * (a[x](f) - 33) + 614125 * (a[x](f + 1) - 33) + 7225 * (a[x](f + 2) - 33) + 85 * (a[x](f + 3) - 33) + (a[x](f + 4) - 33),
  15.     e.push(w & d >> 24, w & d >> 16, w & d >> 8, w & d);
  16.     return function(a, b) {
  17.     for (var c = b; c > 0; c--) a.pop();
  18.     }(e, c[l]), h.fromCharCode.apply(h, e);
  19. }
  20. class B85decode {
  21.     constructor(_key) {
  22.         this.key = _key;
  23.     }
  24.     _read() {
  25.         this._io = {};
  26.         this._debug = {};
  27.     }
  28.     decode(bindata)
  29.     {
  30.         let encoder = new TextEncoder();
  31.         let decoder = new TextDecoder();
  32.         return encoder.encode(decode_ascii85(decoder.decode(bindata)));
  33. //        return encoder.encode(decode_ascii85(String(bindata)));
  34.     }
  35. } this.B85decode = B85decode;
  36. class B85encode {
  37.     constructor(_key) {
  38.         this.key = _key;
  39.     }
  40.     _read() {
  41.         this._io = {};
  42.         this._debug = {};
  43.     }
  44.     decode(bindata)
  45.     {
  46.         let encoder = new TextEncoder();
  47.         let decoder = new TextDecoder();
  48.         return encoder.encode(encode_ascii85(decoder.decode(bindata)));
  49. //        return encoder.encode(encode_ascii85(String(bindata)));
  50.     }
  51. } this.B85encode = B85encode;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement