Cannot decrypt database which is encrypted using SQLCipher 4.0.1

Encrypted database from Android application using SQLCipher 4.0.1. Written a code which decrypt all database files using SQLCipher 3.5.1. Have upgraded SQLite version using “Install-Package System.Data.SQLite -Version 1.0.111”.

My code is:
string path = Path.GetDirectoryName(inputFile);
string baseFilename = Path.GetFileNameWithoutExtension(inputFile);
string outputFile = path + “\” + baseFilename;

 SQLiteCommand cmd = sql.CreateCommand();

            cmd.CommandText = "ATTACH DATABASE '" + outputFile + "'AS outputDB ";             
            cmd.CommandText += "KEY '';";
            cmd.ExecuteNonQuery();

After the statement , getting below run time error:
Failed: code = NotADb (26), message = System.Data.SQLite.SQLiteException (0x800007FF): file is not a database
file is not a database
at System.Data.SQLite.SQLite3.Reset(SQLiteStatement stmt)
at System.Data.SQLite.SQLite3.Step(SQLiteStatement stmt)
at System.Data.SQLite.SQLiteDataReader.NextResult()
at System.Data.SQLite.SQLiteDataReader…ctor(SQLiteCommand cmd, CommandBehavior behave)
at System.Data.SQLite.SQLiteCommand.ExecuteReader(CommandBehavior behavior)
at System.Data.SQLite.SQLiteCommand.ExecuteNonQuery(CommandBehavior behavior)
at System.Data.SQLite.SQLiteCommand.ExecuteNonQuery()

Please help me…

Hello @Vinayak

If you used the default runtime configuration settings when encrypting the database with SQLCipher 4.0.1, you will need to use a 4.x series version of the SQLCipher library instead of 3.5.1 as the 3.x series is not forward compatible to the 4 series in this case.

PRAGMA cipher_compatibility = 3;

Hello @ipse_k - are you having a similar problem? It’s not clear from your post what you mean.