I am glad about the license that can be used and thanks in advance.
Here i provide the code i found working and i use it inside my source.cpp file
The sqlite3.h i got it as is from the project that builds the sqlcipher32.lib not exported but as the project uses it to create the lib.
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include “sqlite3.h”
#pragma comment(lib, “sqlcipher32.lib”)
static int callback(void *NotUsed, int argc, char **argv, char **azColName){
int i;
for (i = 0; i<argc; i++){
printf("%s = %s\n", azColName[i], argv[i] ? argv[i] : “NULL”);
}
printf("\n");
return 0;
}
int sqlite3_key(sqlite3 *db, const void *pKey, int nKey);
int main(int argc, char* argv[])
{
sqlite3 *db;
char *zErrMsg = 0;
int rc;
char sql;
char sqlCommand[400];
const char data = “Callback function called”;
/* Open database */
rc = sqlite3_open("test.db", &db);
if (rc){
fprintf(stderr, "Can't open database: %s\n", sqlite3_errmsg(db));
exit(0);
}
else{
fprintf(stdout, "Opened database successfully\n");
}
/* Encrypt database */
rc = sqlite3_key(db, "1q2w3e4r", 8);
if (rc){
fprintf(stderr, "Can't encrypt database: %s\n", sqlite3_errmsg(db));
exit(0);
}
else{
fprintf(stdout, "Database encrypted successfully\n");
}
/* Create SQL statement */
sql = "CREATE TABLE COMPANY(" \
"ID INT PRIMARY KEY NOT NULL," \
"NAME TEXT NOT NULL," \
"AGE INT NOT NULL," \
"ADDRESS CHAR(50)," \
"SALARY REAL );";
/* Execute SQL statement */
rc = sqlite3_exec(db, sql, callback, 0, &zErrMsg);
if (rc != SQLITE_OK){
fprintf(stderr, "SQL error: %s\n", zErrMsg);
sqlite3_free(zErrMsg);
}
else{
fprintf(stdout, "Table created successfully\n");
}
sprintf(sqlCommand, \
"INSERT INTO COMPANY (ID,NAME,AGE,ADDRESS,SALARY) "\
"VALUES (%d,'%s',%d,'%s',%.2lf); "\
"INSERT INTO COMPANY (ID,NAME,AGE,ADDRESS,SALARY) "\
"VALUES (%d,'%s',%d,'%s',%.2lf); "\
"INSERT INTO COMPANY (ID,NAME,AGE,ADDRESS,SALARY) "\
"VALUES (%d,'%s',%d,'%s',%.2lf); "\
"INSERT INTO COMPANY (ID,NAME,AGE,ADDRESS,SALARY) "\
"VALUES (%d,'%s',%d,'%s',%.2lf); "\
, 1, "Paul", 32, "California", 20000.00
, 2, "Allen", 25, "Texas", 15000.00
, 3, "Teddy", 23, "Norway", 20000.00
, 4, "Mark", 25, "Rich-Mond", 65000.00);
/* Create SQL statement */
/*
sql = "INSERT INTO COMPANY (ID,NAME,AGE,ADDRESS,SALARY) " \
"VALUES (1, 'Paul', 32, 'California', 20000.00 ); " \
"INSERT INTO COMPANY (ID,NAME,AGE,ADDRESS,SALARY) " \
"VALUES (2, 'Allen', 25, 'Texas', 15000.00 ); " \
"INSERT INTO COMPANY (ID,NAME,AGE,ADDRESS,SALARY)" \
"VALUES (3, 'Teddy', 23, 'Norway', 20000.00 );" \
"INSERT INTO COMPANY (ID,NAME,AGE,ADDRESS,SALARY)" \
"VALUES (4, 'Mark', 25, 'Rich-Mond ', 65000.00 );";
*/
/* Execute SQL statement */
rc = sqlite3_exec(db, sqlCommand, callback, 0, &zErrMsg);
if (rc != SQLITE_OK){
fprintf(stderr, "SQL error: %s\n", zErrMsg);
sqlite3_free(zErrMsg);
}
else{
fprintf(stdout, "Records created successfully\n");
}
/* Create SQL statement */
sql = "SELECT * from COMPANY";
/* Execute SQL statement */
rc = sqlite3_exec(db, sql, callback, (void*)data, &zErrMsg);
if (rc != SQLITE_OK){
fprintf(stderr, "SQL error: %s\n", zErrMsg);
sqlite3_free(zErrMsg);
}
else{
fprintf(stdout, "Operation done successfully\n");
}
/* Create merged SQL statement */
sql = "UPDATE COMPANY set SALARY = 25000.00 where ID=1; " \
"SELECT * from COMPANY";
/* Execute SQL statement */
rc = sqlite3_exec(db, sql, callback, (void*)data, &zErrMsg);
if (rc != SQLITE_OK){
fprintf(stderr, "SQL error: %s\n", zErrMsg);
sqlite3_free(zErrMsg);
}
else{
fprintf(stdout, "Operation done successfully\n");
}
/* Create merged SQL statement */
sql = "DELETE from COMPANY where ID=2; " \
"SELECT * from COMPANY";
/* Execute SQL statement */
rc = sqlite3_exec(db, sql, callback, (void*)data, &zErrMsg);
if (rc != SQLITE_OK){
fprintf(stderr, "SQL error: %s\n", zErrMsg);
sqlite3_free(zErrMsg);
}
else{
fprintf(stdout, "Operation done successfully\n");
}
sqlite3_close(db);
return 0;
}
And here are the errors
1>------ Rebuild All started: Project: ConsoleApplication4, Configuration: Release Win32 ------
1> Source.cpp
1>sqlcipher32.lib(sqlite3.obj) : error LNK2001: unresolved external symbol _HMAC_Final
1>sqlcipher32.lib(sqlite3.obj) : error LNK2001: unresolved external symbol _RAND_add
1>sqlcipher32.lib(sqlite3.obj) : error LNK2001: unresolved external symbol _EVP_CIPHER_iv_length
1>sqlcipher32.lib(sqlite3.obj) : error LNK2001: unresolved external symbol _EVP_sha1
1>sqlcipher32.lib(sqlite3.obj) : error LNK2001: unresolved external symbol _HMAC_CTX_cleanup
1>sqlcipher32.lib(sqlite3.obj) : error LNK2001: unresolved external symbol _HMAC_CTX_init
1>sqlcipher32.lib(sqlite3.obj) : error LNK2001: unresolved external symbol _EVP_CIPHER_CTX_set_padding
1>sqlcipher32.lib(sqlite3.obj) : error LNK2001: unresolved external symbol _EVP_CIPHER_key_length
1>sqlcipher32.lib(sqlite3.obj) : error LNK2001: unresolved external symbol _OPENSSL_add_all_algorithms_noconf
1>sqlcipher32.lib(sqlite3.obj) : error LNK2001: unresolved external symbol _HMAC_Update
1>sqlcipher32.lib(sqlite3.obj) : error LNK2001: unresolved external symbol _EVP_CipherInit
1>sqlcipher32.lib(sqlite3.obj) : error LNK2001: unresolved external symbol _RAND_bytes
1>sqlcipher32.lib(sqlite3.obj) : error LNK2001: unresolved external symbol _EVP_CipherFinal
1>sqlcipher32.lib(sqlite3.obj) : error LNK2001: unresolved external symbol _EVP_CIPHER_block_size
1>sqlcipher32.lib(sqlite3.obj) : error LNK2001: unresolved external symbol _EVP_MD_size
1>sqlcipher32.lib(sqlite3.obj) : error LNK2001: unresolved external symbol _EVP_CipherUpdate
1>sqlcipher32.lib(sqlite3.obj) : error LNK2001: unresolved external symbol _EVP_CIPHER_CTX_cleanup
1>sqlcipher32.lib(sqlite3.obj) : error LNK2001: unresolved external symbol _PKCS5_PBKDF2_HMAC_SHA1
1>sqlcipher32.lib(sqlite3.obj) : error LNK2001: unresolved external symbol _EVP_get_cipherbyname
1>sqlcipher32.lib(sqlite3.obj) : error LNK2001: unresolved external symbol _EVP_cleanup
1>sqlcipher32.lib(sqlite3.obj) : error LNK2001: unresolved external symbol _EVP_CIPHER_nid
1>sqlcipher32.lib(sqlite3.obj) : error LNK2001: unresolved external symbol _HMAC_Init_ex
1>sqlcipher32.lib(sqlite3.obj) : error LNK2001: unresolved external symbol _OBJ_nid2sn
1>D:\SQLite_Enc_Tests\Release\ConsoleApplication4.exe : fatal error LNK1120: 23 unresolved externals
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
If i also use the sqlite3.c inside my program these unresolved externals will not exist and instead of it
it will ask me for new headers each time and after using all the headers it will search for crypto.c always
as mentioned in previous posts.