導航:首頁 > 編程大全 > 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資料庫加密相關的資料

熱點內容
文件夾共享連接 瀏覽:531
易到新版本怎麼處理 瀏覽:379
文本文檔怎麼改配置文件 瀏覽:174
列印原文件如何把字體占滿紙張 瀏覽:514
模擬編程有哪些 瀏覽:491
騎馬與砍殺無雙三國升級士兵 瀏覽:366
基因表達強弱范圍用什麼數據分組 瀏覽:782
win10home升級企業版 瀏覽:445
企業資料庫如何建立 瀏覽:377
造假app有哪些 瀏覽:970
不知道寬頻賬號密碼怎麼連接網路 瀏覽:721
卸載喜馬拉雅時顯示找不到文件 瀏覽:858
蜂窩熱點的數據漫遊是什麼 瀏覽:392
樂高建模編程什麼關系 瀏覽:9
win10怎麼創建鏡像文件 瀏覽:324
手機文件轉碼 瀏覽:717
jsp首頁獲取菜單 瀏覽:796
js獲取數組裡面的值嗎 瀏覽:422
東莞哪裡有少兒編程課 瀏覽:782
有的視頻文件無法播放 瀏覽:189

友情鏈接