http://en.wikipedia.org/wiki/Base64#URL_applications
谈论base64Url - 解码
存在修改后的Base64 for URL变体,其中不使用填充'=',标准Base64的'+'和'/'字符分别替换为' - '和'_'
我创建了以下功能:
public static String base64UrlDecode(String input) {
String result = null;
BASE64Decoder decoder = new BASE64Decoder();
try {
result = decoder.decodeBuffer(input.replace('-','+').replace('/','_')).toString();
}
catch (IOException e) {
System.out.println(e.getMessage());
}
return result;
}
Run Code Online (Sandbox Code Playgroud)
它返回一组非常小的字符,甚至与预期的结果不相似.有任何想法吗?