Skip to content

Instantly share code, notes, and snippets.

@mage1k99
Last active May 26, 2019 12:23
Show Gist options
  • Save mage1k99/b631d00137466ae76258df3ba2b4a629 to your computer and use it in GitHub Desktop.
Save mage1k99/b631d00137466ae76258df3ba2b4a629 to your computer and use it in GitHub Desktop.
Causes Error
private boolean cipherinitalize() {
try {
cipherObject = Cipher.getInstance(KeyProperties.KEY_ALGORITHM_AES + "/" + KeyProperties.BLOCK_MODE_CBC + "/" + KeyProperties.ENCRYPTION_PADDING_PKCS7);
keyStoreObject.load(null);
SecretKey secretKeyObject = (SecretKey) keyStoreObject.getKey(key_name,null);
cipherObject.init(Cipher.ENCRYPT_MODE, secretKeyObject);
return true;
} catch (IOException e) {
e.printStackTrace();
Log.e(TAG, "cipherinitalize: IOException error Occared", e);
return false;
} catch (CertificateException e) {
e.printStackTrace();
Log.e(TAG, "cipherinitalize: Certificate Exception",e );
return false;
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
Log.e(TAG, "cipherinitalize: NoSuchAlgorithm exist", e);
return false;
} catch (UnrecoverableKeyException e) {
e.printStackTrace();
Log.e(TAG, "cipherinitalize: UnrecoverableKey Exception", e);
return false;
} catch (InvalidKeyException e) {
e.printStackTrace();
Log.e(TAG, "cipherinitalize: InvalidKeyException",e);
return false;
} catch (NoSuchPaddingException e) {
e.printStackTrace();
Log.e(TAG, "cipherinitalize: NoSuchPaddingException",e );
return false;
} catch (KeyStoreException e) {
e.printStackTrace();
Log.e(TAG, "cipherinitalize: Keystore Exception", e);
return false;
}
}
@mage1k99
Copy link
Author

mage1k99 commented May 26, 2019

The Above Code is a part of Cipherinit(As in the video by EDMT Dev ) method of fingerprint
At line 5 of the snippet The Error Occur Saying java.security.InvalidKeyException: Only SecretKey is supported

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment