title: How to Generate Key and Chiper initiation below Android API 23?
body: <p>Am Using Fingerprint Authentication for App. Want to Support for below API 23 also. For that am Using <strong>FingerprintManagerCompat</strong>. I don't know how to <strong>Generate Key</strong> and <strong>Chiper initiation</strong> in Pre-Android API 23.</p>
  
  <p><strong>Below Code am Used for API 23 - Generate Key</strong></p>
  
  <pre><code>protected void generateKey() {
      try {
          keyStore = KeyStore.getInstance("AndroidKeyStore");
      } catch (Exception e) {
          e.printStackTrace();
      }
  
      try {
          keyGenerator = KeyGenerator.getInstance(KeyProperties.KEY_ALGORITHM_AES, "AndroidKeyStore");
      } catch (NoSuchAlgorithmException |
              NoSuchProviderException e) {
          throw new RuntimeException("Failed to get KeyGenerator instance", e);
      }
  
      try {
          keyStore.load(null);
          keyGenerator.init(new
                  KeyGenParameterSpec.Builder(KEY_NAME,
                  KeyProperties.PURPOSE_ENCRYPT |
                          KeyProperties.PURPOSE_DECRYPT)
                  .setBlockModes(KeyProperties.BLOCK_MODE_CBC)
                  .setUserAuthenticationRequired(true)
                  .setEncryptionPaddings(
                          KeyProperties.ENCRYPTION_PADDING_PKCS7)
                  .build());
          keyGenerator.generateKey();
      } catch (NoSuchAlgorithmException |
              InvalidAlgorithmParameterException
              | CertificateException | IOException e) {
          throw new RuntimeException(e);
      }
  }
  </code></pre>
  
  <p><strong>Below Code am Used for API 23 - Chiper initiation</strong></p>
  
  <pre><code>public boolean cipherInit() {
      try {
          cipher = Cipher.getInstance(KeyProperties.KEY_ALGORITHM_AES + "/" + KeyProperties.BLOCK_MODE_CBC + "/" + KeyProperties.ENCRYPTION_PADDING_PKCS7);
      } catch (NoSuchAlgorithmException |
              NoSuchPaddingException e) {
          throw new RuntimeException("Failed to get Cipher", e);
      }
  
      try {
          keyStore.load(null);
          SecretKey key = (SecretKey) keyStore.getKey(KEY_NAME, null);
          cipher.init(Cipher.ENCRYPT_MODE, key);
          return true;
      } catch (KeyStoreException | CertificateException
              | UnrecoverableKeyException | IOException
              | NoSuchAlgorithmException | InvalidKeyException e) {
          throw new RuntimeException("Failed to init Cipher", e);
      }
  }
  </code></pre>
  
  <p>I don't know how initiate these two things in Pre API 23 to access <strong>FingerprintManagerCompat</strong>, Help me to solve this issue.</p>