Base64Util.java 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package org.zhongzheng.common.utils;
  2. //
  3. // Source code recreated from a .class file by IntelliJ IDEA
  4. // (powered by FernFlower decompiler)
  5. //
  6. import java.nio.charset.Charset;
  7. import org.springframework.util.Base64Utils;
  8. public class Base64Util extends Base64Utils {
  9. public Base64Util() {
  10. }
  11. public static String encode(String value) {
  12. return encode(value, Charsets.UTF_8);
  13. }
  14. public static String encode(String value, Charset charset) {
  15. byte[] val = value.getBytes(charset);
  16. return new String(encode(val), charset);
  17. }
  18. public static String encodeUrlSafe(String value) {
  19. return encodeUrlSafe(value, Charsets.UTF_8);
  20. }
  21. public static String encodeUrlSafe(String value, Charset charset) {
  22. byte[] val = value.getBytes(charset);
  23. return new String(encodeUrlSafe(val), charset);
  24. }
  25. public static String decode(String value) {
  26. return decode(value, Charsets.UTF_8);
  27. }
  28. public static String decode(String value, Charset charset) {
  29. byte[] val = value.getBytes(charset);
  30. byte[] decodedValue = decode(val);
  31. return new String(decodedValue, charset);
  32. }
  33. public static String decodeUrlSafe(String value) {
  34. return decodeUrlSafe(value, Charsets.UTF_8);
  35. }
  36. public static String decodeUrlSafe(String value, Charset charset) {
  37. byte[] val = value.getBytes(charset);
  38. byte[] decodedValue = decodeUrlSafe(val);
  39. return new String(decodedValue, charset);
  40. }
  41. }