加密,解密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