How do I encode/decode short strings as Base64 using GWT?

后端 未结 4 1370
庸人自扰
庸人自扰 2020-12-16 15:07

I need to encode a short String as base 64 in GWT and decode the base 64 string on the server. Anyone have utility class or library for this?

4条回答
  •  醉酒成梦
    2020-12-16 15:26

    You can use native JavaScript for this on the client on all browsers except IE ≤ 9. On the server you can use one of the official classes.

    Java/GWT:

    private static native String b64decode(String a) /*-{
      return window.atob(a);
    }-*/;
    

    Encode is btoa.

提交回复
热议问题