com.soento.core.util.UrlUtil Maven / Gradle / Ivy
package com.soento.core.util;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
/**
* @author soento
*/
public final class UrlUtil {
public static String encrypt(String input, Charset charset) {
try {
return URLEncoder.encode(input, charset.name());
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
}
public static String encrypt(String input) {
return encrypt(input, StandardCharsets.UTF_8);
}
public static String decrypt(String input, Charset charset) {
try {
return URLDecoder.decode(input, charset.name());
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
}
public static String decrypt(String input) {
return decrypt(input, StandardCharsets.UTF_8);
}
}