繁体   English   中英

如何解密/打开(.db)SQLite数据库文件

[英]How to decrypt/open (.db) SQLite database file

如何打开SQLite数据库.db扩展名的文件?

我已经下载了用于SQLite的数据库浏览器。 当我尝试打开数据库文件时,弹出一个新窗口,其中显示“ Titled SQLCipher加密”,询问用于加密的密码和文件大小(与“文件大小”到底是什么混为一谈?)。

我有一个应用程序源代码,可以设法找到密码,并尝试使用默认的页面大小1024。

尝试了几次,但无法打开。

  public void ReadRecord(string sql)
    {
        try
        {
            this.sqlite_cmd.CommandText = this.cSql;
            this.sqlite_datareader = this.sqlite_cmd.ExecuteReader();
            if (this.sqlite_datareader.Read())
            {
                this.sAddEdit = "E";
                this.txt1.Tag = this.sqlite_datareader["id"];
                this.txt1.Text = this.sqlite_datareader["f0"].ToString();
                this.txt2.Text = this.sqlite_datareader["f1"].ToString();
                this.txt3.Text = this.sqlite_datareader["f2"].ToString();
                this.txt4.Text = this.sqlite_datareader["f3"].ToString();
                this.txt5.Text = this.sqlite_datareader["f4"].ToString();
                this.dtpListDate.Text = this.sqlite_datareader["f5"].ToString();
                this.txt7.Text = this.sqlite_datareader["f6"].ToString();
                this.txt8.Text = this.sqlite_datareader["f7"].ToString();
                this.txt9.Text = this.sqlite_datareader["f8"].ToString();
                this.txt10.Text = this.sqlite_datareader["f9"].ToString();
                this.txt11.Text = this.sqlite_datareader["f10"].ToString();
                this.txt12.Text = this.sqlite_datareader["f11"].ToString();
                this.txt13.Text = this.sqlite_datareader["f12"].ToString();
                this.txt14.Text = this.sqlite_datareader["f13"].ToString();
                this.txt15.Text = this.sqlite_datareader["f14"].ToString();
                this.txt16.Text = this.sqlite_datareader["f15"].ToString();
                this.txt17.Text = this.sqlite_datareader["f16"].ToString();
                this.txt18.Text = this.sqlite_datareader["f17"].ToString();
                this.txt19.Text = this.sqlite_datareader["f18"].ToString();
                this.txt20.Text = this.sqlite_datareader["f19"].ToString();
                this.txt21.Text = this.sqlite_datareader["f20"].ToString();
                this.txt22.Text = this.sqlite_datareader["f21"].ToString();
                this.txt23.Text = this.sqlite_datareader["f22"].ToString();
                this.txt24.Text = this.sqlite_datareader["f23"].ToString();
                this.txt25.Text = this.sqlite_datareader["f24"].ToString();
                this.txt26.Text = this.sqlite_datareader["f25"].ToString();
                this.txt27.Text = this.sqlite_datareader["f26"].ToString();
                this.txt28.Text = this.sqlite_datareader["f27"].ToString();
                this.txt29.Text = this.sqlite_datareader["f28"].ToString();
                this.txt30.Text = this.sqlite_datareader["f29"].ToString();
            }
            this.sqlite_datareader.Close();
        }
        catch (Exception exception)
        {
            MessageBox.Show("A Error" + exception.ToString() + " Occcured Please Try Again or contact supplier", "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
        }
    }

在命名空间中

using Microsoft.VisualBasic.PowerPacks;
using System;
using System.ComponentModel;
using System.Data;
using System.Data.SQLite;
using System.Drawing;
using System.IO;
using System.Windows.Forms;

1.关于您关于页面大小的问题,请参阅SQLite数据库文件格式

1.3.2。 页面大小从偏移量16开始的两字节值确定数据库的页面大小。 对于SQLite 3.7.0.1(2010-08-04)及更早版本,此值被解释为big-endian整数,并且必须是512到32768(含)之间的2的幂。 从SQLite版本3.7.1(2010-08-23)开始,支持65536字节的页面大小。 值65536将不适合两个字节的整数,因此要指定65536字节的页面大小,偏移量16处的值为0x00 0x01。 此值可以解释为big-endian 1,并且可以看作表示65536页大小的幻数。 或者可以将两个字节的字段视为一个小端数字,并说它表示页面大小除以256。页面大小字段的这两种解释是等效的。

您可以在普通的sqlite3.exe命令行外壳程序中使用“ .dbinfo”命令来检查数据库的大小。 第一个信息是尺寸

database page size:  4096

2.关于数据库解密假设数据库已加密并且您具有正确的密码(它是以x'或0x开头吗,您是否设法使用数据库浏览器应用程序手动打开数据库?),则必须解密db才能读取它。 请参阅SQLite加密扩展文档 ,以了解有关SQLite加密(和解密)的更多信息。

我建议使用一些开放源码的书面密码。 只需在Google上搜索一下,看看哪一个适合您。 这是一个示例密码,可能会满足您的需求

暂无
暂无

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

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