Base64Coder { public static byte[] decryptBASE64(String str){ if(str==null || str.length()==0){ return null; } byte[] bt = null; sun.misc.BASE64Decoder decoder = new sun.misc.BASE64Decoder(); try { bt = decoder.decodeBuffer(str); } catch (IOException e) { throw new RuntimeException("decrypt base64 error.", e); } return bt; }  static String encryptBASE64(byte[] bstr); static byte[] decryptBASE64(String str);  }
@Test public void testDecryptBASE64() { Assert.assertNull(Base64Coder.decryptBASE64(null)); Assert.assertNull(Base64Coder.decryptBASE64("")); Assert.assertNotNull(Base64Coder.decryptBASE64("ddd")); byte[] i =new byte[]{1}; String s = Base64Coder.encryptBASE64(i); byte[] b = Base64Coder.decryptBASE64(s); Assert.assertEquals(i[0], b[0]); }