Base64Util.java 628 B

123456789101112131415161718192021222324252627
  1. package com.persagy.ztkencryptdecodedata.config;
  2. import org.apache.commons.codec.binary.Base64;
  3. public class Base64Util{
  4. /**
  5. * Decoding to binary
  6. * @param base64 base64
  7. * @return byte
  8. * @throws Exception Exception
  9. */
  10. public static byte[] decode(String base64) throws Exception {
  11. return Base64.decodeBase64(base64);
  12. }
  13. /**
  14. * Binary encoding as a string
  15. * @param bytes byte
  16. * @return String
  17. * @throws Exception Exception
  18. */
  19. public static String encode(byte[] bytes) throws Exception {
  20. return new String(Base64.encodeBase64(bytes));
  21. }
  22. }