當前位置:成語大全網 - 書法字典 - 如何加密和解密SQLite數據庫

如何加密和解密SQLite數據庫

SQLite數據庫的加密和解密方法:

1.創建空的sqlite數據庫。

//可以直接指定數據庫名稱的後綴,甚至可以不加後綴。

//方法壹:創建壹個空的sqlite數據庫,使用IO。

FileStream fs = File。create(" c:\ \ test . db ");

//方法二:使用SQLiteConnection。

SQLiteConnection。create file(" c:\ \ test . db ");

創建的數據庫是壹個0字節的文件。

2.創建壹個加密的空sqlite數據庫。

//創建壹個帶密碼的空sqlite數據庫。

SQLiteConnection。create file(" c:\ \ test 2 . db ");

SQLite connection CNN = new SQLite connection(" Data Source = c:\ \ test 2 . db ");

SQLite connection CNN = new SQLite connection(" Data Source = D:\ \ test 2 . db ");

cnn。open();

cnn。change password(" password ");

3.加密未加密的數據庫

SQLite connection CNN = new SQLite connection(" Data Source = c:\ \ test . db ");

cnn。open();

cnn。change password(" password ");