I'm using it to decrypt a password (said password is in a URI is in another class). If I hardcode the key, it works. I'm trying a dynamic approach, and this is where I struggle due to my lack of experience. I'm not able to get the two classes to work together.
public class Decrypt {
 
    public void myMethod(Context context) {
        try {
            context.getContentResolver().openInputStream(targURI);
        } catch (FileNotFoundException e1) {
                Toast.makeText(context.getApplicationContext(), "Could not read the content. Please check the URI is correct", Toast.LENGTH_LONG).show();
                return;
            }
            BufferedReader reader1 = new BufferedReader(new InputStreamReader(content));
            StringBuffer buffer = new StringBuffer();
            try {
                while ((line = reader1.readLine()) != null) {
                    md5key = md5key + line;
                }
                index = md5key.indexOf("\"MD5_PIN\"");
                md5key = md5key.substring(index + 10, index + 42);
                Log.i("Test:  ", md5key);
            } catch (IOException e1) {
                e1.printStackTrace();
            }
        }
//Decrypts password
    public String encryppass(String pass) {
        return this.decrypt(pass);
    }
    private String decrypt(String paramString) {
        byte[] arrayOfByte = Base64.decode(paramString.getBytes(), 0);
        try {
            this.cipher = Cipher.getInstance("AES");
            this.cipher.init(2, this.keySpec);
            String str = new String(this.cipher.doFinal(arrayOfByte), "UTF-8");
            return str;
        }
        catch (Exception exception) {
            exception.printStackTrace();
            return null;
        }
    }
}
MainActivity:
    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.exploit1:
                String[] arrayOfString = {"name", "pwd"};
                Cursor cursor = getContentResolver().query(
                        Uri.parse(PWDMANAGER_URI), arrayOfString, null, null, null);
                Decrypt pp = new Decrypt();
                try {
                    if (cursor.moveToFirst()) {
                        do {
                            String name = cursor.getString(0);
                            String encrypted = cursor.getString(1);
                            String decrypted1 = pp.encryppass(encrypted);
                            Log.i("Title:     ", name);
                            Log.i("Password:  ", decrypted1);
                        } while (cursor.moveToNext());
                    }
                } catch (NullPointerException exception) {
                    exception.printStackTrace();
                }
   
Any suggestions on how to get these classes working together?
 
    