如何使用 GWT 将短字符串编码/解码为 Base64? [英] How do I encode/decode short strings as Base64 using GWT?

查看:37
本文介绍了如何使用 GWT 将短字符串编码/解码为 Base64?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在 GWT 中将一个短字符串编码为 base 64 并在服务器上解码 base 64 字符串.任何人都有实用程序类或库吗?

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?

推荐答案

除了 IE ≤ 9 之外,所有浏览器的客户端都可以使用原生 JavaScript 来解决这个问题.在服务器上你可以使用 官方课程之一.

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);
}-*/;

编码为btoa.

这篇关于如何使用 GWT 将短字符串编码/解码为 Base64?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆