{"id":13448911,"url":"https://github.com/shenghe/FreeSQLiteEncryption","last_synced_at":"2025-03-22T18:32:10.739Z","repository":{"id":5500637,"uuid":"6699753","full_name":"shenghe/FreeSQLiteEncryption","owner":"shenghe","description":"The Free SQLite Encryption Extension (FSEE)","archived":false,"fork":false,"pushed_at":"2015-10-18T08:22:40.000Z","size":1875,"stargazers_count":87,"open_issues_count":2,"forks_count":31,"subscribers_count":15,"default_branch":"master","last_synced_at":"2024-10-28T15:42:12.900Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/shenghe.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-11-15T04:58:45.000Z","updated_at":"2024-10-22T05:49:33.000Z","dependencies_parsed_at":"2022-09-22T01:52:02.841Z","dependency_job_id":null,"html_url":"https://github.com/shenghe/FreeSQLiteEncryption","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shenghe%2FFreeSQLiteEncryption","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shenghe%2FFreeSQLiteEncryption/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shenghe%2FFreeSQLiteEncryption/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shenghe%2FFreeSQLiteEncryption/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shenghe","download_url":"https://codeload.github.com/shenghe/FreeSQLiteEncryption/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245002892,"owners_count":20545511,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T06:00:24.400Z","updated_at":"2025-03-22T18:32:05.720Z","avatar_url":"https://github.com/shenghe.png","language":"C","readme":"# Free SQLite Encryption Extension (FSEE)\n\nThe Free SQLite Encryption Extension (FSEE) is an add-on to the public domain version of SQLite that allows an application to read and write encrypted database files. Four different encryption algorithms are supported:\n\n\tAES-128 in OFB mode\n\tAES-128 in CCM mode\n\tAES-256 in OFB mode\n\n## COMPILE\n\n1. Download [SQLite 3.7.14.1](http://www.sqlite.org/sqlite-amalgamation-3071401.zip). Unzip it to the \"sqlite3\" folder.\n\n2. Download [Wxsqlite3-3.0.0.1](http://sourceforge.net/projects/wxcode/files/Components/wxSQLite3/). Unzip the “wxsqlite3-3.0.0.1\\wxsqlite3-3.0.0.1\\sqlite3\\secure\\src” folder to \"sqlite3\".\n\n3. Use [visual studio](http://download.microsoft.com/download/B/4/8/B4870509-05CB-447C-878F-2F80E4CB464C/vs_community.exe) to compile the solution.\n\n4. In the bin folder, you will find the \"sqlite.dll\" and \"sqlite.lib\"\n\n5. use the \"sqlite3_key\" and \"sqlite3_rekey\" api\n\n## API\n\n```c\nint sqlite3_key( sqlite3 *db, const void *pKey, int nKey)\n\nint sqlite3_rekey( sqlite3 *db, const void *pKey, int nKey)\n```\n\n## USAGE\n\n```c\n#include\u003cstdio.h\u003e\n#include\u003csqlite3.h\u003e\n#include\u003cstdlib.h\u003e\n\nint main(int argc, char** args)\n{\n    // Create an int variable for storing the return code for each call\n    int retval;\n    \n    // The number of queries to be handled,size of each query and pointer\n    int q_cnt = 5, q_size = 150, ind = 0;\n    char **queries = malloc(sizeof(char) * q_cnt * q_size);\n        \n    // A prepered statement for fetching tables\n    sqlite3_stmt *stmt;\n    \n    // Create a handle for database connection, create a pointer to sqlite3\n    sqlite3 *handle;\n    \n    // try to create the database. If it doesnt exist, it would be created\n    // pass a pointer to the pointer to sqlite3, in short sqlite3**\n    retval = sqlite3_open(\"sampledb.sqlite3\", \u0026handle);\n    retval = sqlite3_key(handle, \"password\", 3);\n    // If connection failed, handle returns NULL\n    if(retval)\n    {\n        printf(\"Database connection failed\\n\");\n        return -1;\n    }\n    printf(\"Connection successful\\n\");\n    \n    // Create the SQL query for creating a table\n    char create_table[100] = \"CREATE TABLE IF NOT EXISTS users (uname TEXT PRIMARY KEY,pass TEXT NOT NULL,activated INTEGER)\";\n    \n    // Execute the query for creating the table\n    retval = sqlite3_exec(handle,create_table, 0, 0, 0);\n    \n    // Insert first row and second row\n    queries[ind++] = \"INSERT INTO users VALUES('manish', 'mani', 1)\";\n    retval = sqlite3_exec(handle,queries[ind-1], 0, 0, 0);\n\n    queries[ind++] = \"INSERT INTO users VALUES('mehul','pulsar',0)\";\n    retval = sqlite3_exec(handle,queries[ind-1], 0, 0, 0);\n    \n    // select those rows from the table\n    queries[ind++] = \"SELECT * from users\";\n    retval = sqlite3_prepare_v2(handle,queries[ind-1], -1, \u0026stmt, 0);\n    if(retval)\n    {\n        printf(\"Selecting data from DB Failed\\n\");\n        return -1;\n    }\n    \n    // Read the number of rows fetched\n    int cols = sqlite3_column_count(stmt);\n        \n    while(1)\n    {\n        // fetch a row's status\n        retval = sqlite3_step(stmt);\n        \n        if(retval == SQLITE_ROW)\n        {\n            // SQLITE_ROW means fetched a row\n            \n            // sqlite3_column_text returns a const void* , typecast it to const char*\n            for(int col=0; col \u003c cols; col++)\n            {\n                const char *val = (const char*)sqlite3_column_text(stmt, col);\n                printf(\"%s = %s\\t\",sqlite3_column_name(stmt,col),val);\n            }\n            printf(\"\\n\");\n        }\n        else if(retval == SQLITE_DONE)\n        {\n            // All rows finished\n            printf(\"All rows fetched\\n\");\n            break;\n        }\n        else\n        {\n            // Some error encountered\n            printf(\"Some error encountered\\n\");\n            return -1;\n        }\n    }\n    \n    // Close the handle to free memory\n    sqlite3_close(handle);\n    return 0;\n}\n```\n\n\n## LICENSE\n\nCopyright 2015 shenghe\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.","funding_links":[],"categories":["encryption and decryption","Encryption and Security"],"sub_categories":["Peer-to-Peer"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshenghe%2FFreeSQLiteEncryption","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshenghe%2FFreeSQLiteEncryption","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshenghe%2FFreeSQLiteEncryption/lists"}