javax.crypto.BadPaddingException:给定最终块未正确填充以进行aes解密

时间:2016-05-02 14:21:41

标签: java

BadPadding异常。

鉴于最终块未正确填充以进行aes解密: javax.crypto.BadPaddingException

代码如下

try
    {
        String val[];
        String text="";
        if(get.contains(","))
        {
            val=get.split(",");
            text=val[0];
        }
        else
        {
            text = get;
        }
        pubtxt2.setText(""+text.length());
        String key=cipkey;
        Key aesKey = new SecretKeySpec(key.getBytes(), "AES");
        Cipher cipher = Cipher.getInstance("AES");
        cipher.init(Cipher.DECRYPT_MODE, aesKey);
        byte sam[]=hextobin(text);
        String decrypted = new String(cipher.doFinal(sam));
        output.setText(decrypted);
        chk=decrypted;
        pubtxt3.setText(""+chk.length());
        a2++;
    }
    catch(Exception e)
    {
        System.err.println(e);
    }

0 个答案:

没有答案