com.i2soft.util.UrlSafeBase64 Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of i2up-java-sdk Show documentation
Show all versions of i2up-java-sdk Show documentation
Information2 United Data Management Platform SDK for Java
package com.i2soft.util;
/**
* URL安全的Base64编码和解码
*/
public final class UrlSafeBase64 {
private UrlSafeBase64() {
} // don't instantiate
/**
* 编码字符串
*
* @param data 待编码字符串
* @return 结果字符串
*/
public static String encode(String data) {
return encode(data.getBytes(Constants.UTF_8));
}
/**
* 编码数据
*
* @param data 字节数组
* @return 结果字符串
*/
public static String encode(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 - 2025 Weber Informatics LLC | Privacy Policy