Issue while using Android fingerprint: IV required when decrypting. Use IvParameterSpec or AlgorithmParameters to provide it

后端 未结 3 860
春和景丽
春和景丽 2021-02-04 04:38

I\'m following the ConfirmCredential Android example provided by Google, but it only shows how to encrypt the data. When I try to decrypt it I get exception:

ja         


        
3条回答
  •  花落未央
    2021-02-04 05:23

    I created an issue in the github project for the sample provided by google (link to the issue here). The response I got is that I must use the IV that was generated when the value was encrypted. (same as in the solution provided by @Qianqian)

    cipher.init(Cipher.DECRYPT_MODE, secretKey, new IvParameterSpec(encryptCipher.getIV()));
    byte[] decryptedBytes = cipher.doFinal(encryptedBytes);
    

    I created a sample application that shows how to do this. It is available on github, here.

    Hope this is useful to someone.

提交回复
热议问题