title: How to store an AES password in a SQLite database in Android?
body: <p>I am trying to store a password in a SQLite database using this code:</p>
  
  <pre><code>public static String encrypt(String Data) throws Exception {
      Key key = generateKey();
      Cipher c = Cipher.getInstance(ALGO);
      c.init(Cipher.ENCRYPT_MODE, key);
      byte[] encVal = c.doFinal(Data.getBytes());
      String encryptedValue = new BASE64Encoder().encode(encVal);
      return encryptedValue;
  }
  
  public static String decrypt(String encryptedData) throws Exception {
      Key key = generateKey();
      Cipher c = Cipher.getInstance(ALGO);
      c.init(Cipher.DECRYPT_MODE, key);
      byte[] decordedValue = new BASE64Decoder().decodeBuffer(encryptedData);
      byte[] decValue = c.doFinal(decordedValue);
      String decryptedValue = new String(decValue);
      return decryptedValue;
  }
  
  private static Key generateKey() throws Exception {
      Key key = new SecretKeySpec(keyValue, ALGO);
      return key;
  }
  </code></pre>
  
  <p>and this byte array as key</p>
  
  <pre><code>private static final byte[] keyValue = 
          new byte[] { 'T', 'h', 'e', 'B', 'e', 's', 't',
              'S', 'e', 'c', 'r','e', 't', 'K', 'e', 'y' };
  </code></pre>
  
  <p>but the problem is where to store that key, because using that key, anybody can decrypt the data and cause security issues..</p>
  
  <p>Please help me....Thanks in advance..</p>