private boolean initCipher() {
        try {
            //Obtain a cipher instance and configure it with the properties required for fingerprint authentication//
            if(this.cipher == null) {
                this.cipher = Cipher.getInstance(
                        KeyProperties.KEY_ALGORITHM_AES + "/"
                                + KeyProperties.BLOCK_MODE_CBC + "/"
                                + KeyProperties.ENCRYPTION_PADDING_PKCS7);
            }
        } catch (NoSuchAlgorithmException |
                NoSuchPaddingException e) {
            e.printStackTrace();
            return false;
        }
        try {
            if(this.secretKey == null) {
                this.secretKey = generateKey();
            }
            if(this.keyStore != null) {
                if(!this.keystoreInitialized) {
                    this.keyStore.load(null);
                    this.keystoreInitialized = true;
                }
            }
//            key = (SecretKey) this.keyStore.getKey(keyName, null); todo needed?
            if(this.cipher != null) {
                if (!this.cipherInitialized) {
                    this.cipher.init(Cipher.ENCRYPT_MODE, this.secretKey);
                    this.cipherInitialized = true;
                }
            }
            //Return true if the cipher has been initialized successfully//
            return true;
        } catch (KeyPermanentlyInvalidatedException e) {
            //Return false if cipher initialization failed//
            return false;
        } catch (CertificateException //KeyStoreException
                | IOException //UnrecoverableKeyException
                | NullPointerException
                | NoSuchAlgorithmException | InvalidKeyException e) {
            e.printStackTrace();
            return false;
        }
    }
private boolean initCipher() {
        try {
           
            if(this.cipher == null) {
                this.cipher = Cipher.getInstance(
                        KeyProperties.KEY_ALGORITHM_AES + "/"
                                + KeyProperties.BLOCK_MODE_CBC + "/"
                                + KeyProperties.ENCRYPTION_PADDING_PKCS7);
            }
        } catch (NoSuchAlgorithmException |
                NoSuchPaddingException e) {
            e.printStackTrace();
            return false;
        }
        try {
            if(this.secretKey == null) {
                this.secretKey = generateKey();
            }
            if(this.keyStore != null) {
                if(!this.keystoreInitialized) {
                    this.keyStore.load(null);
                    this.keystoreInitialized = true;
                }
            }
            if(this.cipher != null) {
                if (!this.cipherInitialized) {
                    this.cipher.init(Cipher.ENCRYPT_MODE, this.secretKey);
                    this.cipherInitialized = true;
                }
            }
           
            return true;
        } catch (KeyPermanentlyInvalidatedException e) {
           
            return false;
        } catch (CertificateException
                | IOException
                | NullPointerException
                | NoSuchAlgorithmException | InvalidKeyException e) {
            e.printStackTrace();
            return false;
        }
    }
private boolean initcipher() { try { if(this.cipher == null) { this.cipher = cipher.getinstance( keyproperties.key_algorithm_aes + "/" + keyproperties.block_mode_cbc + "/" + keyproperties.encryption_padding_pkcs7); } } catch (nosuchalgorithmexception | nosuchpaddingexception e) { e.printstacktrace(); return false; } try { if(this.secretkey == null) { this.secretkey = generatekey(); } if(this.keystore != null) { if(!this.keystoreinitialized) { this.keystore.load(null); this.keystoreinitialized = true; } } if(this.cipher != null) { if (!this.cipherinitialized) { this.cipher.init(cipher.encrypt_mode, this.secretkey); this.cipherinitialized = true; } } return true; } catch (keypermanentlyinvalidatedexception e) { return false; } catch (certificateexception | ioexception | nullpointerexception | nosuchalgorithmexception | invalidkeyexception e) { e.printstacktrace(); return false; } }