Daily Archives: June 25, 2011

how to create assembly in .net 3.5


1. Create new project using Class Library

Click on picture to clear picture



2. Create code like this.

3. And, build the project.

4. And then create your web or windows application and add Reference using following steps,


5.browse DLL file From MyFirstAssembly bin\Debug

 6.Add NameSpace using MyFirstAssembly and write code like this

7.Finally Run your project

how to set password for sqllite database?


SQLiteCrypt API

SQLiteCrypt is very easy to use. SQLiteCrypt is based on SQLite, so most API functions remain unchanged. Please refer to SQLite documenttation. SQLiteCrypt modifies only one SQLite function:

staticint sqlite3_open( //same syntax for sqlite3_open16

constchar *zFilename, // IN: Database filename UTF-8 encoded

const char *strPass, //IN: Pass Phrase

sqlite3 **ppDb /* OUT: Returned database handle */ )

New openDatabase method has 3 parameters, instead of 2 in original SQLite openDatabase. New parameter is pass-phrase.

Only added function in SQLiteCrypt is sqlite3_changepassword:

void sqlite3_changepassword(

sqlite3* db, //IN: Database handle

constchar* strNewPass/*IN: New pass phrase, up to 128 characters*/)

Remark: Do not call sqlite3_changepassword function in middle of transaction, or when database is not committed (if auto commit turned off). This method decrypt whole database using old pass phrase, then encrypt using new pass phrase. You can continue to use SQLite API functions, no need of closing and re-opening database. sqlite3_changepassword is time-consuming operation.

Example 1: Encrypt SQLite database

sqlite3 *pDb;

int rc = openDatabase(zFilename, “”, &pDb); //Open regular (non-encrypted) SQLite database

//execute SQL commands here, but finish all transactions and commit before call sqlite3_changepassword

sqlite3_changepassword(pDb, “new pass phrase”); //encrypt database

//execute SQL commands here 

Example 2: Decrypt SQLite database (remove encryption, so any other SQLite application can open it)

sqlite3 *pDb;

int rc = openDatabase(zFilename, “pass phrase”, &pDb); //Open encrypted SQLite database

//execute SQL commands here, but finish all transactions and commit before call sqlite3_changepassword

sqlite3_changepassword(pDb, “”); //decrypt database by supplying empty pass phrase

//execute SQL commands here

Example 3: Change encryption key on-the-fly

sqlite3 *pDb;

int rc = openDatabase(zFilename, “pass phrase”, &pDb); //Open encrypted SQLite database

//execute SQL commands here, but finish all transactions and commit before call sqlite3_changepassword

sqlite3_changepassword(pDb, “new pass phrase”); //change encryption key by supplying new pass phrase

//execute SQL commands here

SQLiteCrypt command line tool

Download SQLiteCrypt command line tool here. SQLiteCrypt command line tool source code is here. You can compare with original command line tool source code available in SQLite distribution.

Using SQLiteCrypt command line tool:

Example 1: Create new regular SQLite database, then encrypt it

D:\>sqlite.exe test.db
SQLite version 3.3.8
Enter “.help” for instructions
sqlite> create table Test(a INT, b INT);
sqlite> insert into Test values(327, 86);
sqlite> select * from Test;
327|86
sqlite> .changepass 12345678
sqlite> select * from Test;
327|86
sqlite> .exit

Example 2: Create encrypted database

D:\>sqlite.exe 12345678 test.db
SQLite version 3.3.8
Enter “.help” for instructions
sqlite> create table Test(a INT, b INT);
sqlite> insert into Test values(327, 86);
sqlite> select * from Test;
327|86
sqlite> .exit

Example 3: Open encrypted database using wrong pass phrase

Supply wrong pass phrase:

D:\>sqlite.exe pass test.db
Unable to open database “test.db”: supplied password is incorrect

No pass phrase supplied:

D:\>sqlite.exe test.db
SQLite version 3.3.8
Enter “.help” for instructions
sqlite> select * from Test;
SQL error: database disk image is malformed
sqlite> .exit

Example 4: Open encrypted database query, then make it regular SQLite database (remove encryption)

D:\>sqlite.exe 12345678 test.db
SQLite version 3.3.8
Enter “.help” for instructions
sqlite> select * from Test;
327|86
sqlite> .changepass
sqlite> select * from Test;
327|86
sqlite> .exit

Example 5: Open encrypted database, make queries, then change pass phrase

D:\>sqlite.exe 12345678 test.db
SQLite version 3.3.8
Enter “.help” for instructions
sqlite> select * from Test;
327|86
sqlite> .changepass 87654321
sqlite> select * from Test;
327|86
sqlite> .exit

D:\>sqlite.exe 87654321 test.db
SQLite version 3.3.8
Enter “.help” for instructions
sqlite> select * from Test;
327|86
sqlite> .exit

Refer by: http://sqlite-crypt.com/documentation.htm