Code: Select all
private SecretKey decryptDataKey(String encryptedDataKeyString) throws NoSuchAlgorithmException, InvalidKeyException,
NoSuchPaddingException, IllegalBlockSizeException, BadPaddingException, UnrecoverableKeyException, java.security.KeyStoreException, InvalidAlgorithmParameterException, NoSuchProviderException {
java.security.Key masterKey = getOrCreateKey();
Cipher cipher = Cipher.getInstance(transformation);
cipher.init(Cipher.DECRYPT_MODE, masterKey); // No GCMParameterSpec
byte[] encryptedDataKey = android.util.Base64.decode(encryptedDataKeyString, android.util.Base64.DEFAULT); // Correct Base64 class
byte[] decryptedDataKey = cipher.doFinal(encryptedDataKey);
return new SecretKeySpec(decryptedDataKey, KeyProperties.KEY_ALGORITHM_AES);
}
[img]https:/ /i.sstatic.net/IYXvdFOW.png[/img]
aber der Code erzeugte einen Fehler "java.security.InvalidKeyException: IV beim Entschlüsseln erforderlich stellen Sie es zur Verfügung .Key)
Ich frage Gemini und andere Ai und bitte sogar darum, dieses Rezept speziell zu implementieren. Problem bei der Verwendung von Android-Fingerabdruck: IV beim Entschlüsseln erforderlich. Verwenden Sie IvParameterSpec oder AlgorithmParameters, um es bereitzustellen, aber es ist fehlgeschlagen. Die KI versteht auch, was in der Zeile cipher.init(Cipher.DECRYPT_MODE, masterKey)