{"id":15290842,"url":"https://github.com/zhouchangsheng/sqlcipher","last_synced_at":"2025-04-13T10:12:50.574Z","repository":{"id":46097069,"uuid":"98488301","full_name":"zhouchangsheng/sqlcipher","owner":"zhouchangsheng","description":"SQLCipher 是一个基于openssl加密功能sqlite3","archived":false,"fork":false,"pushed_at":"2017-10-29T07:02:37.000Z","size":1110,"stargazers_count":24,"open_issues_count":2,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-13T10:12:48.304Z","etag":null,"topics":["sliqte3","sqlcipher","sqlite-database"],"latest_commit_sha":null,"homepage":"https://zhouchangsheng.github.io/#!/zh-CN/content/database/sqlcipher","language":"JavaScript","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/zhouchangsheng.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":"2017-07-27T03:08:09.000Z","updated_at":"2025-03-31T07:35:05.000Z","dependencies_parsed_at":"2022-09-09T15:51:15.204Z","dependency_job_id":null,"html_url":"https://github.com/zhouchangsheng/sqlcipher","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhouchangsheng%2Fsqlcipher","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhouchangsheng%2Fsqlcipher/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhouchangsheng%2Fsqlcipher/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhouchangsheng%2Fsqlcipher/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zhouchangsheng","download_url":"https://codeload.github.com/zhouchangsheng/sqlcipher/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248695482,"owners_count":21146956,"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":["sliqte3","sqlcipher","sqlite-database"],"created_at":"2024-09-30T16:09:43.121Z","updated_at":"2025-04-13T10:12:50.553Z","avatar_url":"https://github.com/zhouchangsheng.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# sqlcipher\n\u003e sqlcipher 是一个基于openssl加密功能sqlite3。形式上增加一些与加密功能相关`sql`语句；本质上是一个经过重新编译的sqlite3，不破坏原有功能，仅仅增添了加密特性。\n\n### 简介\nSQLCipher是开源SQLite的一个扩展，此处不是作为SQLite插件，而是指扩展其功能，扩展[sqlite API](https://github.com/mapbox/node-sqlite3/wiki/API)，因为SQLCipher需要重新编译SQLite，最终生成一个集成加密功能的`node_sqlit3.node`node文件。SQLCipher对**整个数据库文件加密**。SQLCipher安装不需要复杂的配置环境，一般系统有`npm`就可以针对一些环境进行安装，在过程中会自动安装构建的依赖项。与加密功能的sql语句往往放置最前面，一般是连接数据库之后，就执行这些语句。\n\n### 支持平台 \n * C/C++\n * Obj-C\n * QT\n * Win32/.NET\n * Java\n * Python\n * Ruby\n * Linux\n * Mac OS X\n * iPhone/IOS\n * Android\n * Xamarin.IOS\n * Xamarin.Android\n * Electron\n\n\n\n### 用法\n\n```javascript\nvar SQLite3 = require('sqlcipher').verbose();\nvar sqlite = new SQLite3.Database('./test-win.db');\n\nsqlite.run(\"pragma key = 'secret'\");\nsqlite.run(\"pragma cipher = 'aes-256-cbc'\");//optional, default cipher be eqaul to 'aes-256-cbc'\n```\n注意：sqlcipher该插件是在sqlite3的基础上增添了加密功能。因此，使用sqlcipher可以对数据库文件进行加密或不加密。如果要对数据库文件进行加密，则连接（创建）数据库文件后，第一条`sql`语句必须是`pragma key = '...'`，否则将会出现意想不到的错误。\n\n### 安装\n```bash\nnpm install sqlcipher \n```\n通过运行以上命令，将会根据系统的环境编译出相应（系统下node版本以及node位数）的sqlciher。默认支持以下三种系统环境。\n\n- windows\n- mac\n- linux\n\n通过携带参数可以在指定环境下进行编译。[特定环境安装](https://github.com/zhouchangsheng/sqlcipher/wiki/%E5%AE%89%E8%A3%85)\n```bash\nnpm install sqlcipher --target=`目标运行环境版本号` --target_arch=`目标运行环境位数` --dist-url=`目标运行环境下载地址` --runtime=`目标运行环境`\n```\n\n\n### 加密算法\nsqlcipher基于openssl加密库，支持多种加密算法，在实际开发中可以使用默认算法aes-256-cbc或者在[支持的加密算法](https://github.com/zhouchangsheng/sqlcipher/wiki/%E5%8A%A0%E5%AF%86%E7%AE%97%E6%B3%95)中选择其中某一个。\n* aes-128-cbc\n* aes-192-cfb\n* aes-256-cbc(默认)\n* cast \n* rc4\n\n### API\nsqlcipher 常用api有指定加密秘钥、指定加密算法、更换秘钥等。当然，如果需要改善加密环境下的sqlite性能，有更详细的[api](https://www.zetetic.net/sqlcipher/sqlcipher-api/)（即`sql`语句）去优化项目。\n\n1.加密秘钥\n```bash\npragma key = 'secret';\n```\n\n2.加密算法\n\n```bash\npragma cipher = 'aes-128-cbc';\n```\n\n3.更换秘钥\n\n```bash\npragma rekey = 'aes-128-cbc';\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzhouchangsheng%2Fsqlcipher","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzhouchangsheng%2Fsqlcipher","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzhouchangsheng%2Fsqlcipher/lists"}