{"id":28450454,"url":"https://github.com/houbb/encryption-local","last_synced_at":"2025-10-26T19:37:10.599Z","repository":{"id":293844397,"uuid":"469319375","full_name":"houbb/encryption-local","owner":"houbb","description":"金融敏感数据加密。姓名加解密，身份证加解密，邮箱加解密，手机加解密，银行卡加解密，银行卡加解密。","archived":false,"fork":false,"pushed_at":"2025-05-18T13:24:28.000Z","size":56,"stargazers_count":10,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-02T04:59:16.401Z","etag":null,"topics":["bankno","email","mobile","name","password","safe","secret","sensitive"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/houbb.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-03-13T09:02:10.000Z","updated_at":"2025-08-01T01:04:59.000Z","dependencies_parsed_at":"2025-05-17T14:32:46.863Z","dependency_job_id":null,"html_url":"https://github.com/houbb/encryption-local","commit_stats":null,"previous_names":["houbb/encryption-local"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/houbb/encryption-local","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/houbb%2Fencryption-local","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/houbb%2Fencryption-local/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/houbb%2Fencryption-local/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/houbb%2Fencryption-local/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/houbb","download_url":"https://codeload.github.com/houbb/encryption-local/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/houbb%2Fencryption-local/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270016562,"owners_count":24512963,"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","status":"online","status_checked_at":"2025-08-12T02:00:09.011Z","response_time":80,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["bankno","email","mobile","name","password","safe","secret","sensitive"],"created_at":"2025-06-06T15:07:30.253Z","updated_at":"2025-10-26T19:37:05.560Z","avatar_url":"https://github.com/houbb.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# encryption-local\n\n[encryption-local](https://github.com/houbb/encryption-local) 一个离线版本的金融敏感信息加解密工具，用于数据库敏感信息存储。\n\n创作目的：为金融敏感数据，提供一个简单易用的离线加解密工具。加密机服务可以在此基础上很容易的实现。\n\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.github.houbb/encryption-local/badge.svg)](http://mvnrepository.com/artifact/com.github.houbb/encryption-local)\n[![Build Status](https://www.travis-ci.org/houbb/encryption-local.svg?branch=master)](https://www.travis-ci.org/houbb/encryption-local?branch=master)\n[![Coverage Status](https://coveralls.io/repos/github/houbb/encryption-local/badge.svg?branch=master)](https://coveralls.io/github/houbb/encryption-local?branch=master)\n\n## 特性\n\n- 身份证加解密\n\n- 地址加解密\n\n- 姓名加解密\n\n- 邮箱加解密\n\n- 手机号加解密\n\n- 银行卡加解密\n\n- 密码加解密\n\n## 项目推荐\n\n下面是一些日志、加解密、脱敏安全相关的库推荐：\n\n| 项目                                                                    | 介绍                    |\n|:----------------------------------------------------------------------|:----------------------|\n| [sensitive-word](https://github.com/houbb/sensitive-word)             | 高性能敏感词核心库             |\n| [sensitive-word-admin](https://github.com/houbb/sensitive-word-admin) | 敏感词控台，前后端分离           |\n| [sensitive](https://github.com/houbb/sensitive)                       | 高性能日志脱敏组件             |\n| [auto-log](https://github.com/houbb/auto-log)                         | 统一日志切面组件，支持全链路traceId |\n| [encryption-local](https://github.com/houbb/encryption-local)         | 离线加密机组件               |\n| [encryption](https://mp.weixin.qq.com/s/2LQuKvll9EIn6pyFjhwacw)         | 加密机标准API+本地客户端        |\n| [encryption-server](https://mp.weixin.qq.com/s/2LQuKvll9EIn6pyFjhwacw)        | 加密机服务                 |\n\n## 拓展阅读\n\n[【老马】离线版金融敏感信息加解密组件开源项目encryption-local](https://mp.weixin.qq.com/s/ba99l_NUHW6Zv8BCBAqfzg)\n\n[【藏经阁】加密机服务完整解决方案，包含客户端+服务端](https://mp.weixin.qq.com/s/2LQuKvll9EIn6pyFjhwacw)\n\n# 变更日志\n\n\u003e [变更日志](CHANGELOG.md)\n\n# 快速开始 \n\n## 需要 \n\njdk1.7+\n\nmaven 3.x+\n\n## maven 引入 \n\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003ecom.github.houbb\u003c/groupId\u003e\n    \u003cartifactId\u003eencryption-local-core\u003c/artifactId\u003e\n    \u003cversion\u003e1.2.0\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n## 方法概览\n\n常见方法都在 `EncryptionLocalUtil#xxx` 工具类中可见。\n\n### 加密\n\n| 方法                | 说明    |\n|:------------------|:------|\n| addressEncrypt    | 地址加密  |\n| nameEncrypt       | 姓名加密  |\n| emailEncrypt      | 邮箱加密  |\n| phoneEncrypt      | 手机号加密 |\n| idCardEncrypt     | 身份证加密 |\n| bankCardNoEncrypt | 银行卡加密 |\n| passwordEncrypt   | 密码加密  |\n\n统一入参：`(text, salt)` text 为待加密的内容, salt 为秘钥。v1.1.0 支持不带 salt 的方法。\n\n统一出参：`CommonEncryptResponse` 对象，有 3 个属性：\n\n| 属性 | 说明 |\n|:---|:---|\n| cipher | 密文 |\n| mask | 掩码 |\n| hash | 摘要 |\n\n### 解密\n\n| 方法                | 说明    |\n|:------------------|:------|\n| addressDecrypt    | 地址解密  |\n| nameDecrypt       | 姓名解密  |\n| emailDecrypt      | 邮箱解密  |\n| phoneDecrypt      | 手机号解密 |\n| idCardDecrypt     | 身份证解密 |\n| bankCardNumDecrypt | 银行卡解密 |\n| passwordDecrypt   | 密码解密  |\n\n统一入参：`cipher` 为加密之后的密文字符串\n\n统一出参：解密之后的明文字符串\n\n## 使用\n\n用法都是类似的，此处以手机号为例：\n\n```java\nfinal String email = \"18888888888\";\nfinal String salt = \"99886622\";\n\nCommonEncryptResponse response = EncryptionLocalUtil.phoneEncrypt(email, salt);\nString cipher = response.getCipher();\nString mask = response.getMask();\nString hash = response.getHash();\nAssert.assertEquals(\"08276740AEC8AAC11C6D0F84184DE2B5\", cipher);\nAssert.assertEquals(\"188****8888\", mask);\nAssert.assertEquals(\"381FA900C0626D7D7E2DB185B3558166\", hash);\n\n// 解密\nString plain = EncryptionLocalUtil.phoneDecrypt(cipher, salt);\nAssert.assertEquals(email, plain);\n```\n\n其他的各种数据效果示例整理如下，秘钥统一使用 `99886622`。\n\n注意：生产环境使用，**必须保证秘钥的复杂性（建议不低于 10 位）**。\n\n| 类别  | 明文                      | 秘文 | 掩码 | 摘要 |\n|:----|:------------------------|:---|:---|:---|\n| 地址  | 太平洋比基尼海滩比奇堡镇贝壳街124号的波萝屋 | D8D9E99FB8286107C2F75325C0B9046CF335EE4AC4FCD3F27E0D6BFD8B3DBF39440A3D69422A3AF933576798CF3860F330F288E196CEACB22CCCDA0623B94355 | `太平洋比基尼*************的波萝屋` | 31912515337902B8A3CC1CBDB5772358 |\n| 姓名  | 海绵宝宝                    | 91AF56071FA8830391144DBEAE3967DA | `海**宝` | 94B221D98E0EF588B5304A88752DC6C7 |\n| 邮箱  | haimian@baobao.com      | 15768CD9C0E70E2C798451E7982C8877DF991568ECD7BC3E1A9E9AD72455B085 | `hai****@baobao.com` | 4C651B4CDACA3CFA4876277B678282A9 |\n| 手机  | 18888888888             | 08276740AEC8AAC11C6D0F84184DE2B5 | `188****8888` | 381FA900C0626D7D7E2DB185B3558166 |\n| 身份证 | 330781198509079479      | 74101E0AAF25796680E40F3198D1AEFBC00E25FD8316F40CE90B425338894A42 | `330781*********479` | 2C7E7A814C36DE11EF01F39C35CECF12 |\n| 银行卡 | 4427290920309717        | 288D5EC5432203677D3714E9A270F9998AC04BF65E5A36C6773187A4239D05EE | `442729******9717` | DE550BAF362B3EF640FF5AEC7D6E2F38 |\n| 密码  | 123456                  | 8B208237BEB2E6A4390E7128E5E000D7 | `******` | FEB408A10822A55A939E8E38A6612515 |\n\n\u003e 完整例子参考 [EncryptionLocalUtilTest.java](https://github.com/houbb/encryption-local/blob/master/encryption-local-test/src/test/java/com/github/houbb/encryption/local/test/EncryptionLocalUtilTest.java)\n\n## 引导类\n\n为了便于用于拓展，加密支持通过引导类 `EncryptionLocalBs` 灵活指定配置。\n\n### 配置\n\nEncryptionLocalBs 中支持用户自定义下列配置。\n\n| 属性 | 说明 | 默认值 |\n|:---|:---|:---|\n| salt | 秘钥 | null |\n| hash | 哈希策略 | md5 |\n| secret | 加密策略 | aes |\n\n在指定秘钥之后，其他方法不再需要传递秘钥。\n\n方法和工具类中一致。\n\n### 例子\n\n```java\nEncryptionLocalBs localBs = EncryptionLocalBs.newInstance();\n\n// 加密\nCommonEncryptResponse encryptResponse = localBs.encrypt(\"123456\", EncryptTypeEnum.PASSWORD.getCode());\nAssert.assertEquals(\"CommonEncryptResponse{cipher='8B208237BEB2E6A4390E7128E5E000D7', mask='******', hash='FEB408A10822A55A939E8E38A6612515'}\", encryptResponse.toString());\n\n// 解密\nString plainText = localBs.decrypt(encryptResponse.getCipher(), EncryptTypeEnum.PASSWORD.getCode());\nAssert.assertEquals(\"123456\", plainText);\n```\n\n# ROAD-MAP\n\n- [ ] 允许用户自定义实现策略\n\n- [ ] 基于注解的属性映射\n\n@Address  \n\n_cipher _mask _hash\n\n数据库写入的正向处理，读取的反向处理\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhoubb%2Fencryption-local","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhoubb%2Fencryption-local","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhoubb%2Fencryption-local/lists"}