0

我正在使用 AES 进行加密解密并且工作正常。但是对于安全检查,我已经对文件进行了一些更改。现在,当我再次运行时,它会在抛出错误的行上崩溃

javax.crypto.IllegalBlockSizeException: last block incomplete in decryption

. 我已经放置了日志和标志,但它没有到达下一行。请建议我如何处理这个异常。我也使用了 try catch 但没有工作。代码片段是“:

            DataBaseActivity myDbHelper;
        File myFile1 = new File(filing1);   //Date.txt
        FileInputStream fIn = null;
        String  dateDec= null;
        String[] date = null;
        Boolean flag = null;
        Calendar cal1 = null;
        Calendar cal2 = null;

        try {
            fIn = new FileInputStream(myFile1);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }

        BufferedReader myReader = new BufferedReader(new InputStreamReader(fIn));

        String aDataRow1 = "";
        String aBuffer1 = "";

        try {
            while ((aDataRow1 = myReader.readLine()) != null) {
                aBuffer1 += aDataRow1;

                myReader.close();
                dateDec = AESencrp.decrypt(aBuffer1); 
                System.out.println("Datedec"+dateDec);
                if(dateDec == ""){
                    flag = false;
                }else {
                    flag = true;
                }
            }
        } catch (IllegalBlockSizeException e) {
            e.printStackTrace();
        }catch (NullPointerException e) {
            e.printStackTrace();
        }

        if(flag == true) {

        try
        {   
                System.out.println("checks1");
                //DataBaseActivity openHelperClass = new DataBaseActivity(this);
                myDbHelper = new DataBaseActivity(this);
              //  myDbHelper = new DataBaseActivity(this);

               System.out.println("checks2");
                try {
                    System.out.println("checks3");
                    myDbHelper.createDataBase();
                    System.out.println("checks4");

            } catch (IOException ioe) {

                throw new Error("Unable to create database");

            }

异常上线dateDec = AESencrp.decrypt(aBuffer1);

4

0 回答 0