各位兄弟帮帮忙!如题,我在windows下访问liunx下的应用。解密抛javax.crypto.BadPaddingException: Given final block not properly padded异常.请问是何原因啊。困扰好几天了。

解决方案 »

  1.   

     private byte[] getDesCode(byte[] byteD) {
            Cipher cipher;
            byte[] byteFina = null;
            try {
                cipher = Cipher.getInstance("DES/ECB/PKCS5Padding");  
                cipher.init(Cipher.DECRYPT_MODE, key);
                byteFina = cipher.doFinal(byteD);
            } catch (Exception e) {
             e.printStackTrace();
             throw new RuntimeException (" getDesCode Exception :" + e.getMessage());
            } finally {
                cipher = null;
            }
            return byteFina;    }