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

熱點內容
什麼是plist文件 瀏覽:470
刷小說的app有什麼不好用 瀏覽:553
如何識別數據線的安全性 瀏覽:801
惠普6520s升級 瀏覽:496
vmware12共享網路 瀏覽:918
安卓lollipop有什麼用 瀏覽:841
ps如何去除掃描文件黑邊 瀏覽:643
傳奇天下魂珠寶石升級 瀏覽:349
網路突然不可用該怎麼辦 瀏覽:583
ps做好了幀怎麼保存文件 瀏覽:409
sqlite3資料庫加密 瀏覽:45
linux怎麼增加磁碟空間 瀏覽:382
為什麼要燒文件呢 瀏覽:732
康佳網路電視怎麼看直播 瀏覽:293
c啟動外部程序參數 瀏覽:269
linux鏈接文件拷貝 瀏覽:914
華為怎麼更改賬號密碼忘記了怎麼辦啊 瀏覽:788
什麼是krc文件 瀏覽:705
bi數據分析師需要會什麼 瀏覽:582
UG編程指定部件怎麼選片體 瀏覽:693

友情鏈接