Skip to content
This repository has been archived by the owner on Aug 30, 2021. It is now read-only.

Commit

Permalink
Allowing to add a password, and not only to remove one.
Browse files Browse the repository at this point in the history
  • Loading branch information
davdiv committed Jun 3, 2014
1 parent 1648342 commit a19ea8c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 17 deletions.
17 changes: 8 additions & 9 deletions DecryptSQLite.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ static void start ()
{
String sourceFile = null;
String destinationFile = null;
String password = "password";
String sourcePassword = "password";
String destinationPassword = "";

const string FILTER = "Base de données (*.db3)|*.db3|Tous les fichiers (*.*)|*.*";
FileDialog sourceFileSelection = new OpenFileDialog ();
Expand All @@ -42,26 +43,24 @@ static void start ()
}
destinationFile = destinationFileSelection.FileName;

password = Interaction.InputBox ("Mot de passe pour\n" + sourceFile, "Mot de passe", password);
if (password.Length == 0) {
return;
}
sourcePassword = Interaction.InputBox ("Mot de passe pour\n" + sourceFile, "Ancien mot de passe", sourcePassword);
destinationPassword = Interaction.InputBox ("Mot de passe pour\n" + destinationFile, "Nouveau mot de passe", destinationPassword);

const string CONNECTION_STRING = "URI=file:{0};Version=3;Password={1};";
if (!sourceFile.Equals (destinationFile)) {
File.Copy (sourceFile, destinationFile);
}
String connectionString = String.Format (CONNECTION_STRING, destinationFile, password);
String connectionString = String.Format (CONNECTION_STRING, destinationFile, sourcePassword);

try {
SQLiteConnection connection = new SQLiteConnection (connectionString);
connection.Open ();
try {
connection.ChangePassword ("");
connection.ChangePassword (destinationPassword);
connection.Close ();
MessageBox.Show ("Mot de passe supprimé avec succès!", "Succès", MessageBoxButtons.OK, MessageBoxIcon.Information);
MessageBox.Show ("Mot de passe changé avec succès!", "Succès", MessageBoxButtons.OK, MessageBoxIcon.Information);
} catch (Exception e) {
MessageBox.Show ("Erreur lors de la suppression du mot de passe:\n" + e, "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
MessageBox.Show ("Erreur lors du changement de mot de passe:\n" + e, "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
} catch (Exception e) {
MessageBox.Show ("Erreur lors de l'ouverture de la base de données:\n" + e, "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
Expand Down
21 changes: 13 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# DecryptSQLite

This repository contains a simple utility, written in C#, which allows to remove the password from
This repository contains a simple utility, written in C#, which allows to change the password of
an encrypted SQLite database (created with [System.Data.SQLite](https://system.data.sqlite.org)).

Note that you have to know the password in order to remove it (the goal of this utility is not to
help recovering a lost password).
Note that you have to know the old password in order to change it (the goal of this utility is
not to help recovering a lost password).

## How to build

Expand All @@ -25,14 +25,19 @@ It might not be compatible with other versions.

* Execute `DecryptSQLite.exe` (e.g. by double-clicking on it).

* A dialog box to select the database file is displayed. Please select the SQLite encrypted
database file (.db3) and click on Open.
* A dialog box to select the database file is displayed. Please select the source SQLite database
file (.db3) and click on Open.

* Another dialog box then asks where to save the unencrypted database. You can change the default path
* Another dialog box then asks where to save the changed database. You can change the default path
(if needed) and validate by clicking on Save.

* Another dialog box then asks for the password to decrypt the encrypted database. Type the password
and click OK.
* Another dialog box then asks for the password of the source database to decrypt it. Type
the password and click on OK. If the source database is not encrypted, you can either click on Cancel
or empty the field and click on OK.

* Another dialog box then asks for the new password to encrypt the database. Type the new password
and click on OK. If you don't want to encrypt the changed database, you can either click on Cancel,
or make sure the field is empty and click on OK.

* When the password removal operation completes successfully, a success message is displayed.
Otherwise, an error message can be displayed.
Expand Down
Binary file modified bin/Release/DecryptSQLite.exe
Binary file not shown.

0 comments on commit a19ea8c

Please sign in to comment.