Base64 encoding vs Ascii85 encoding

前端 未结 3 956
说谎
说谎 2020-12-31 08:02

My project at work is using the Jackson JSON serializer to convert a bunch of Java objects into Strings in order to send them to REST services.

Some of these objects

3条回答
  •  不思量自难忘°
    2020-12-31 08:38

    Here is matching ASCII85 AKA Base85 decoder (for user Qwerty) in JavaScript:

    function decode_ascii85(a) {
      var c, d, e, f, g, h = String, l = "length", w = 255, x = "charCodeAt", y = "slice", z = "replace";
      for ("<~" === a[y](0, 2) && "~>" === a[y](-2), a = a[y](2, -2)[z](/\s/g, "")[z]("z", "!!!!!"), 
      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), 
      e.push(w & d >> 24, w & d >> 16, w & d >> 8, w & d);
      return function(a, b) {
        for (var c = b; c > 0; c--) a.pop();
      }(e, c[l]), h.fromCharCode.apply(h, e);
    }
    
    

    example: <~<+oue+DGm>@3BW*D/a<&+EV19F<L~>

提交回复
热议问题