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

lxkprmvk  于 2022-11-24  发布在  SQLite
关注(0)|答案(1)|浏览(910)

如何打开SQLite数据库中扩展名为.db的文件?
我已经下载了一个数据库浏览器为SQLite。当我试图打开数据库文件,一个新的窗口弹出,这是'标题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;
yiytaume

yiytaume1#

**1.关于页面大小的问题,**请参阅SQLite Database file Format

1.3.2.页面大小从偏移量16开始的双字节值决定了数据库的页面大小。对于SQLite版本3.7.0.1(2010-08-04)及更早版本中,此值被解释为big-endian整数,并且必须是介于512与32768之间(包括512与32768)的2的幂。(2010-08-23),支持65536字节的页面大小。值65536不适合两字节的整数,因此要指定65536字节的页面大小,偏移量16处的值为0x 00 0x 01。此值可解释为big-endian 1,并可视为表示65536页大小的幻数。也可以将双字节字段视为小字节序数字,并将其表示为页面大小除以256。这两种对页面大小字段的解释是等效的。
您可以在普通sqlite3.exe命令行shell程序中使用."dbinfo”命令检查数据库的大小。

database page size:  4096

2.关于数据库解密假设数据库已加密,并且您有正确的密码,(它是以x'还是0x开头?您是否设法使用数据库浏览器应用程序手动打开数据库?),您必须先解密数据库,然后才能读取它。请参阅SQLite Encryption Extension Documentation,以了解有关SQLite加密(和解密)的更多信息。

我建议使用一些开源的书面密码。只是谷歌它,看看哪一个是舒适的为您工作。here's an example cipher that might be good for your needs

相关问题