java Base 64编码和解码示例代码
有人知道如何使用Base64对Base64中的字符串进行解码和编码吗。我正在使用以下代码,但它不起作用
String source = "password";
byte[] byteArray = source.getBytes("UTF-16");
Base64 bs = new Base64();
//bs.encodeBytes(byteArray);
System.out.println( bs.encodeBytes(byteArray));
//bs.decode(bs.encodeBytes(byteArray));
System.out.println(bs.decode(bs.encodeBytes(byteArray)));
# 1 楼答案
要加密:
要解密:
# 2 楼答案
对于Kotlinmb,最好使用以下选项:
例如:
# 3 楼答案
对于在这里搜索如何解码用
Base64.encodeBytes()
编码的字符串的信息的其他人,我的解决方案如下:另外,我支持旧版本的Android,所以我使用的是来自http://iharder.net/base64的Robert Harder的Base64库
# 4 楼答案
如果您使用的是Kotlin,请像这样使用
用于编码
用于解码
# 5 楼答案
差不多