繁体   English   中英

我可以用密码加密SQLite数据库吗?

[英]Can i password encrypt SQLite database?

我使用SQLite数据库版本3与C#Windows应用程序..我想使用密码或任何其他加密方式加密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();
    }

此后如果用户试图打开数据库。 会说管理员受保护或者数据库是加密的,还是不是数据库或损坏的文件!

在这个论坛发现一个帖子表明..

Standard SQLite3 API doesn't offer any form of protection and relies only on underlying OS privileges mecanism (if any) for "security". If you have an existing SQLite-style database which uses a specific API to gain access, then you should use this particular (non-standard) API.

如果您可以/想要为SQLite使用某种扩展,您还可以尝试SQLite加密扩展(SEE)SQLite Crypt

但您可以使用SQLite.Data更改/设置数据库的密码,如本文所示。

尝试使用sqlitestudio.pl作为编辑器。
对于Database Type,在连接时选择System.Data.SQLite

不幸的是,SQlite文件中的密码只能从代码中添加或删除或更改。 为此,您需要System.Data.SQLite命名空间,它将为您提供方法以及适配器和连接。

您可以使用sq-lite .net提供程序(System.Data.SQLite)的内置加密。 试试这个:

http://sqlite.phxsoftware.com/forums/t/130.aspx 在此处输入链接说明

或使用:

SQLiteCrypt API

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM