導航:首頁 > 編程大全 > sqlite3資料庫加密

sqlite3資料庫加密

發布時間:2024-10-05 18:30:46

① python 如何訪問加密的sqlite3資料庫

你的 sqlite3資料庫是用 SEE 加密的嗎? 如果是了話,試一下通過python執行以下sqlite pragma命令來提供解密key

PRAGMAkey='your-secret-key';


根據 SEE的文檔,通過 PRAGMA 命令也可以提供解密key,而不需sqlite3_key_v2() 這個C API。你試一下。

② 怎麼加密和解密sqlite資料庫

加密一個未加密的資料庫或者更改一個加密資料庫的密碼,打開資料庫,啟動SQLiteConnection的ChangePassword() 函數

// Opens an unencrypted database

SQLiteConnection cnn = newSQLiteConnection("Data Source=c:\\test.db3");

cnn.Open();

// Encrypts the database. The connection remains valid and usable afterwards.

cnn.ChangePassword("mypassword");

解密一個已加密的資料庫調用l ChangePassword() 將參數設為 NULL or "" :

// Opens an encrypted database

SQLiteConnection cnn = newSQLiteConnection("Data Source=c:\\test.db3;Password=mypassword");

cnn.Open();

// Removes the encryption on an encrypted database.

cnn.ChangePassword("");

要打開一個已加密的資料庫或者新建一個加密資料庫,在打開或者新建前調用SetPassword()函數

// Opens an encrypted database by calling SetPassword()

SQLiteConnection cnn = newSQLiteConnection("Data Source=c:\\test.db3");

cnn.SetPassword(newbyte[] { 0xFF, 0xEE, 0xDD, 0x10, 0x20, 0x30 });
cnn.Open();

// The connection is now usable

Sqlite資料庫的加密

1、創建空的sqlite資料庫。

//資料庫名的後綴你可以直接指定,甚至沒有後綴都可以
//方法一:創建一個空sqlite資料庫,用IO的方式
FileStream fs = File.Create(「c:\\test.db「);
//方法二:用SQLiteConnection
SQLiteConnection.CreateFile(「c:\\test.db「);

創建的資料庫是個0位元組的文件

2、創建加密的空sqlite資料庫

//創建一個密碼為password的空的sqlite資料庫
SQLiteConnection.CreateFile(「c:\\test2.db「);
SQLiteConnection cnn = new SQLiteConnection(「Data Source=c:\\test2.db「);
SQLiteConnection cnn = new SQLiteConnection(「Data Source=D:\\test2.db「);
cnn.Open();
cnn.ChangePassword(「password「);

3、給未加密的資料庫加密

SQLiteConnection cnn = new SQLiteConnection(「Data Source=c:\\test.db「);
cnn.Open();
cnn.ChangePassword(「password「);

4、打開加密sqlite資料庫

//方法一
SQLiteConnection cnn = new SQLiteConnection(「Data Source=c:\\test2.db「);
cnn.SetPassword(「password「);
cnn.Open();
//方法二
SQLiteConnectionStringBuilder builder = new SQLiteConnectionStringBuilder();
builder.DataSource = @」c:\test.db「;
builder.Password = @」password「;
SQLiteConnection cnn = new SQLiteConnection(builder.ConnectionString);
cnn .Open();

分頁

select * from messages limit 10,100;

表示跳過10行,取100行的返回結果。

閱讀全文

與sqlite3資料庫加密相關的資料

熱點內容
源文件名太長什麼意思 瀏覽:573
linux文件復制到u盤 瀏覽:141
4558升級代換 瀏覽:589
泰國支持什麼網路 瀏覽:939
ps鉛筆畫用什麼工具上色 瀏覽:108
5s升級ios93會不會卡 瀏覽:775
驅動安裝完了找不到文件夾 瀏覽:717
金醫保app可以預約哪些醫院 瀏覽:840
如果快速刪掉電腦桌面文件 瀏覽:309
網路優化系統是什麼 瀏覽:320
海康威視數據怎麼刪除 瀏覽:826
ug編程哪個視圖好用 瀏覽:866
福州龍泉哪裡有學編程的 瀏覽:513
消保整改文件 瀏覽:145
重度貧血數據是多少 瀏覽:323
maya粒子表達式教程 瀏覽:84
抖音小視頻如何掛app 瀏覽:283
cad怎麼設置替補文件 瀏覽:790
win10啟動文件是空的 瀏覽:397
jk網站有哪些 瀏覽:134

友情鏈接