c# - 我可以密码加密 SQLite 数据库吗?

标签 c# sql database sqlite

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

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

编辑

如果我从代码加密它,客户端可以在安装完成时打开它,并且在打开程序执行加密之前将 db 文件传输到程序文件,不是吗?

最佳答案

我使用 SQLite 版本 3 完美运行! 你必须这样做:

//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!

关于c# - 我可以密码加密 SQLite 数据库吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12190672/

相关文章:

ruby-on-rails - “拆分”ActiveRecord 集合

database - 获取 Apache Derby 中表使用的空间

c# - 通过构建器模式使用异步任务

c# - 自定义类 ASP.Net 5 MVC 6 中的应用程序设置

sql - 报告的错误代码是否被认为是 SQL 注入(inject)?

sql - H2数据库中的Oracle MERGE语句

python - 谷歌应用引擎持久全局变量

c# - 使用 SignalR 和 IProgress 接口(interface)的进度报告

c# - ASP.NET 设计问题 - 工厂与动态选择代码隐藏(如果可能的话)

mysql - 仅当值不存在时返回行