com.qiniu.util.UrlSafeBase64 Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of qiniu-java-sdk Show documentation
Show all versions of qiniu-java-sdk Show documentation
Qiniu Cloud Storage SDK for Java
package com.qiniu.util;
import com.qiniu.common.Constants;
/**
* URL安全的Base64编码和解码
*/
public final class UrlSafeBase64 {
private UrlSafeBase64() {
} // don't instantiate
/**
* 编码字符串
*
* @param data 待编码字符串
* @return 结果字符串
*/
public static String encodeToString(String data) {
return encodeToString(data.getBytes(Constants.UTF_8));
}
/**
* 编码数据
*
* @param data 字节数组
* @return 结果字符串
*/
public static String encodeToString(byte[] data) {
return Base64.encodeToString(data, Base64.URL_SAFE | Base64.NO_WRAP);
}
/**
* 解码数据
*
* @param data 编码过的字符串
* @return 原始数据
*/
public static byte[] decode(String data) {
return Base64.decode(data, Base64.URL_SAFE | Base64.NO_WRAP);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy