{"id":16464613,"url":"https://github.com/deatil/go-cryptobin","last_synced_at":"2025-04-07T14:16:06.721Z","repository":{"id":45154504,"uuid":"477228005","full_name":"deatil/go-cryptobin","owner":"deatil","description":"go 常用加密解密库/go encrypt or decrypt pkg（RSA/SM2/EIGamal/Gost/AES/DES/TripleDes/SM4/Tea/Twofish）","archived":false,"fork":false,"pushed_at":"2024-04-13T13:09:32.000Z","size":3541,"stargazers_count":202,"open_issues_count":0,"forks_count":18,"subscribers_count":6,"default_branch":"main","last_synced_at":"2024-04-14T05:11:06.091Z","etag":null,"topics":["aes","bks","crypto","des","dsa","ecdh","ecdsa","gmsm","golang","jceks","jks","pkcs12","pkcs7","pkcs8","rsa","sm2","ssh-key"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/deatil/go-cryptobin","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/deatil.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2022-04-03T03:27:06.000Z","updated_at":"2024-08-15T17:20:53.404Z","dependencies_parsed_at":"2023-02-18T08:16:00.280Z","dependency_job_id":"55b8818b-1dd9-437d-8a1b-60c52ba1ecdb","html_url":"https://github.com/deatil/go-cryptobin","commit_stats":null,"previous_names":[],"tags_count":174,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deatil%2Fgo-cryptobin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deatil%2Fgo-cryptobin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deatil%2Fgo-cryptobin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deatil%2Fgo-cryptobin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/deatil","download_url":"https://codeload.github.com/deatil/go-cryptobin/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247666015,"owners_count":20975788,"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":["aes","bks","crypto","des","dsa","ecdh","ecdsa","gmsm","golang","jceks","jks","pkcs12","pkcs7","pkcs8","rsa","sm2","ssh-key"],"created_at":"2024-10-11T11:28:48.484Z","updated_at":"2025-04-07T14:16:06.693Z","avatar_url":"https://github.com/deatil.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"## go-cryptobin\n\ngo-cryptobin 是 go 的常用加密解密库\n\n中文 | [English](README_EN.md)\n\n\n### 项目介绍\n\n*  go-cryptobin 包括常用的对称加密和非对称加密及签名验证\n*  对称加密解密（Aes/Des/TripleDes/SM4/Tea/Twofish/Xts）\n*  对称加密解密模式（ECB/CBC/PCBC/CFB/NCFB/OFB/NOFB/CTR/GCM/CCM）\n*  对称加密解密补码（NoPadding/ZeroPadding/PKCS5Padding/PKCS7Padding/X923Padding/ISO10126Padding/ISO97971Padding/ISO7816_4Padding/PBOC2Padding/TBCPadding/PKCS1Padding）\n*  非对称加密解密（RSA/SM2/ElGamal）\n*  非对称签名验证（RSA/RSA-PSS/DSA/ECDSA/EC-GDSA/EdDSA/SM2/ElGamal/ED448/Gost）\n*  默认 `Aes`, `ECB`, `NoPadding`\n\n\n### 环境要求\n\n - Go \u003e= 1.20\n\n\n### 下载安装\n\n~~~go\ngo get -u github.com/deatil/go-cryptobin\n~~~\n\n\n### 开始使用\n\n~~~go\npackage main\n\nimport (\n    \"fmt\"\n\n    \"github.com/deatil/go-cryptobin/cryptobin/crypto\"\n)\n\nfunc main() {\n    // 加密\n    cypten := crypto.\n        FromString(\"useData\").\n        SetKey(\"dfertf12dfertf12\").\n        SetIv(\"dfertf12dfertf12\").\n        Aes().\n        CBC().\n        PKCS7Padding().\n        Encrypt().\n        ToBase64String()\n\n    // 解密\n    cyptde := crypto.\n        FromBase64String(cypten).\n        SetKey(\"dfertf12dfertf12\").\n        SetIv(\"dfertf12dfertf12\").\n        Aes().\n        CBC().\n        PKCS7Padding().\n        Decrypt().\n        ToString()\n\n    fmt.Println(\"加密结果：\", cypten)\n    fmt.Println(\"解密结果：\", cyptde)\n}\n\n~~~\n\n\n### 结构说明\n\n*  默认方式 `Aes`, `ECB`, `NoPadding`。默认没有用补码, 默认输入值需为 16 长度倍数, 不是正确长度可以使用其他补码\n~~~go\n// 加密数据\ncypt := crypto.\n    FromString(\"useData5useData5\").\n    SetKey(\"dfertf12dfertf12\").\n    Encrypt().\n    ToBase64String()\n\n// 解密数据\ncyptde := crypto.\n    FromBase64String(\"eZf7c3fcwKlmrqogiEHbJg==\").\n    SetKey(\"dfertf12dfertf12\").\n    Decrypt().\n    ToString()\n~~~\n\n*  结构说明\n~~~go\n// 使用代码\n// 注意: 设置密码,加密类型,加密模式,补码方式 在 操作类型 之前, 可以调换顺序\nret := crypto.\n    FromString(\"string\"). // 数据来源, 待加密数据/待解密数据\n    SetKey(\"key_string\"). // 设置密码\n    SetIv(\"iv_string\").   // 设置向量\n    Aes().                // 加密类型\n    CBC().                // 加密模式\n    PKCS7Padding().       // 补码方式\n    Encrypt().            // 操作类型, 加密或者解密\n    ToBase64String()      // 返回结果数据类型\n~~~\n\n\n### 可用方法\n\n*  数据来源:\n`FromBytes(data []byte)`, `FromString(data string)`, `FromBase64String(data string)`, `FromHexString(data string)`\n*  设置密码:\n`SetKey(data string)`, `WithKey(key []byte)`\n*  设置向量:\n`SetIv(data string)`, `WithIv(iv []byte)`\n*  加密类型:\n`Aes()`, `Des()`, `TripleDes()`, `Twofish()`, `Blowfish()`, `Tea(rounds ...int)`, `Xtea()`, `Cast5()`, `RC4()`, `Idea()`, `SM4()`, `Chacha20(counter ...uint32)`, `Chacha20poly1305(additional ...[]byte)`, `Xts(cipher string, sectorNum uint64)`\n*  加密模式:\n`ECB()`, `CBC()`, `PCBC()`, `CFB()`, `OFB()`, `CTR()`, `GCM(additional ...[]byte)`, `CCM(additional ...[]byte)`\n*  补码方式:\n`NoPadding()`, `ZeroPadding()`, `PKCS5Padding()`, `PKCS7Padding()`, `X923Padding()`, `ISO10126Padding()`, `ISO7816_4Padding()`,`ISO97971Padding()`,`PBOC2Padding()`, `TBCPadding()`, `PKCS1Padding(bt ...string)`\n*  操作类型:\n`Encrypt()`, `Decrypt()`, `FuncEncrypt(f func(Cryptobin) Cryptobin)`, `FuncDecrypt(f func(Cryptobin) Cryptobin)`\n*  返回数据类型:\n`ToBytes()`, `ToString()`, `ToBase64String()`, `ToHexString()`\n\n*  更多信息可以查看 [文档](docs/README.md)\n\n\n### 开源协议\n\n*  本软件包遵循 `Apache2` 开源协议发布，在保留本软件包版权的情况下提供个人及商业免费使用。\n\n\n### 版权\n\n*  本软件包所属版权归 deatil(https://github.com/deatil) 所有。\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeatil%2Fgo-cryptobin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdeatil%2Fgo-cryptobin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeatil%2Fgo-cryptobin/lists"}