ewfwefwefpwfpkpewfpkoewfkowf

ewfwefwefpwfpkpewfpkoewfkowf

本文介绍了在Android / Java中的cipher.doFinal中传递什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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:错误:1e000065:密码函数:OPENSSL_internal:BAD_DECRYPT

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

[wefopwfpkpewfpkoewfkowfewfwefwefpwfpkpewfpkoewfkowfewfwefwefpwfpkpewfpkoewfkowfewfwefwefpwfpkpewfpkoewfkowfewfwefwefpwfpkpewfpkoewfkowfewfwefwefpwfpkpewfpkoewfkowfewfwefwefpwfpkpewfpkoewfkowfewfwefwefpwfpkpewfpkoewfkowfewfwefwefpwfpkpewfpkoewfkowfewfwefwefpwfpkpewfpkoewfkowfewfwefwefpwfpkpewfpkoewfkowfewfwefwefpwfpkpewfpkoewfkowfewfwefwef]bhdfuiyh

推荐答案

您正在尝试解密密钥,我想您需要解密apiResponse

You are trying to decrypt the "key", I think you need to decrypt the apiResponse

此外,您需要使用与消息加密时完全相同的IV,否则您将无法解密

Also you need the exact same IV the message was encrypted with, otherwise you won't be able to decrypt

这篇关于在Android / Java中的cipher.doFinal中传递什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-19 07:47