我可以密码加密SQLite数据库吗? [英] Can i password encrypt SQLite database?

查看:250
本文介绍了我可以密码加密SQLite数据库吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用SQLite数据库版本3与C#Windows应用程序..
i要使用密码或任何其他加密方式加密SQLite数据库文件,以防止客户端从程序文件文件夹中打开它。

I am using SQLite database version 3 with C# Windows application.. i want to encrypt the SQLite database file using password or any other encryption way in order to prevent clients to open it from program files folder.

我不想要任何运行时加密方式,我只是想让数据库文件显示密码字段,当客户端尝试从程序文件中打开它。感谢

i don't want any runtime encryption ways, i just want to make the database file show password field when a client try to open it from the program files .. thanks

编辑

Edit

客户端可以在安装完成时打开它,并且在打开程序之前将db文件传输到程序文件以执行加密。

and if i encrypted it from code,the client can open it when the installation complete and db file transferred to the program files before opening the program to perform the encryption isnt it?

推荐答案

我使用SQLite版本3完美的工作!
你必须这样做:

I use SQLite version 3 works perfectly! You have to do that:

//if the database has already password
try{
            string conn = @"Data Source=database.s3db;Password=Mypass;";
            SQLiteConnection connection= new SQLiteConnection(conn);
            connection.Open();
            //Some code
            connection.ChangePassword("Mypass");
            connection.Close();
    }
//if it is the first time sets the password in the database
catch
    {
            string conn = @"Data Source=database.s3db;";
            SQLiteConnection connection= new SQLiteConnection(conn);
            connection.Open();
            //Some code
            connection.ChangePassword("Mypass");
            connection.Close();
    }




。将被管理员保护或数据库被加密或不是数据库或损坏的文件!

thereafter if the user tries to open the database. will say protected by Admin or the database is encrypted or is not a database or corrupted file!

这篇关于我可以密码加密SQLite数据库吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆