org.springframework.util.Base64Utils
String str = "abc"; String encode = new String(Base64Utils.encode(str.getBytes())); System.out.println("加密后:" + encode); String decode = new String(Base64Utils.decode(encode.getBytes()), "utf8"); System.out.println("解密后:" + decode);