在高并发下,正确的做法如下:
- /**
- * BASE64解密
- *
- * @param key
- * @return
- * @throws Exception
- */
- public static String decryptBASE64(String key) throws Exception {
- if(key==null||key.length()<1){
- return "";
- }
- return new String(new BASE64Decoder().decodeBuffer(key));
- }
- /**
- * BASE64加密
- *
- * @param key
- * @return
- * @throws Exception
- */
- public static String encryptBASE64(String key) throws Exception {
- if(key==null||key.length()<1){
- return "";
- }
- return new String(new BASE64Encoder().encodeBuffer(key.getBytes()));
- }