javax.crypto.BadPaddingException: Given final block not properly padded

加密算法:BASE64 (3DES (SHA1(原始字符串)))

 

public static String base64Encode(byte[] str)
{
BASE64Encoder encoder = new BASE64Encoder();
return encoder.encodeBuffer(str);
}

public static byte[] base64Decode(String str)
{
BASE64Decoder dec = new BASE64Decoder();
try
{
return dec.decodeBuffer(str);  // 如果这里返回的是dec.decodeBuffer(str).toString() 那么在3DES解密时会报标题的错误
}
catch (IOException io)
{
throw new RuntimeException(io.getMessage(), io.getCause());
}
}

posted @ 2013-07-31 14:56  古道悠悠  阅读(520)  评论(0编辑  收藏  举报