小编典典

在Android / Java中的cipher.doFinal中传递什么?

java

Android代码

String apiResponse = "EcUZvMif

方法:

protected void decryptDataWithAES(String apiResponse, String key) {
        try {
            es(StandardCharsets.UTF_8);


            byte[] decodedResult = Base64.decode(apiResponse, Base64.NO_WRAP);

           terSpec = new IvParameterSpec(first16ByteArray);

            SecretKeySpec skey = new SecretKeySpec(byteArray, "AES");

            Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
            cipher.init(DECRYPT_MODE, skey, ivParameterSpec);

            String decryptString = new String(cipher.doFinal(byteArray), StandardCharsets.UTF_8);
            showLog("JSON: " + decryptString);

        } catch (Exception e) {
            e.printStackTrace();

        }
    }

例外: javax.crypto.BadPaddingException: error:1e000065:Cipher functions:OPENSSL_internal:BAD_DECRYPT

[wefopwfpkpewfpkoewfkowf ewfwefwefpwfpkpewfpkoewfkowf
ewfwefwefpwfpkpewfpkoewfkowf ewfwefwefpwfpkpewfpkoewfkowf
ewfwefwefpwfpkpewfpkoewfkowf ewfwefwefpwfpkpewfpkoewfkowf
ewfwefwefpwfpkpewfpkoewfkowf ewfwefwefpwfpkpewfpkoewfkowf
ewfwefwefpwfpkpewfpkoewfkowf ewfwefwefpwfpkpewfpkoewfkowf
ewfwefwefpwfpkpewfpkoewfkowf ewfwefwefpwfpkpewfpkoewfkowf ewfwefwef] bhdfuiyh


阅读 1143

收藏
2020-11-30

共1个答案

小编典典

您正在尝试解密“密钥”,我认为您需要解密apiResponse

另外,您需要使用与邮件加密时完全相同的IV,否则您将无法解密

2020-11-30