{"id":23087620,"url":"https://github.com/exp-codes/pyc-cross-crypto","last_synced_at":"2025-09-03T14:37:37.482Z","repository":{"id":168716673,"uuid":"644475828","full_name":"EXP-Codes/pyc-cross-crypto","owner":"EXP-Codes","description":"python \u0026 c++ 跨平台加解密","archived":false,"fork":false,"pushed_at":"2023-07-05T05:22:38.000Z","size":17749,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-04-03T16:49:12.326Z","etag":null,"topics":["aes","cpp","crypto","des","programming","python"],"latest_commit_sha":null,"homepage":"","language":"C++","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/EXP-Codes.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,"publiccode":null,"codemeta":null}},"created_at":"2023-05-23T15:37:40.000Z","updated_at":"2023-05-23T16:57:23.000Z","dependencies_parsed_at":null,"dependency_job_id":"05cef387-5998-48ff-b0e8-bba0e36777d6","html_url":"https://github.com/EXP-Codes/pyc-cross-crypto","commit_stats":null,"previous_names":["exp-codes/pyc-cross-crypto"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/EXP-Codes/pyc-cross-crypto","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EXP-Codes%2Fpyc-cross-crypto","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EXP-Codes%2Fpyc-cross-crypto/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EXP-Codes%2Fpyc-cross-crypto/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EXP-Codes%2Fpyc-cross-crypto/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/EXP-Codes","download_url":"https://codeload.github.com/EXP-Codes/pyc-cross-crypto/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EXP-Codes%2Fpyc-cross-crypto/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273457652,"owners_count":25109277,"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-09-03T02:00:09.631Z","response_time":76,"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":["aes","cpp","crypto","des","programming","python"],"created_at":"2024-12-16T19:59:15.166Z","updated_at":"2025-09-03T14:37:37.460Z","avatar_url":"https://github.com/EXP-Codes.png","language":"C++","readme":"# pyc-cross-crypto\n\n\u003e python \u0026 c++ 跨平台加解密\n\n------\n\n## 0x00 前言\n\n由于 python 和 C++ 的 AES/DES 填充算法存在细微差异（应该说是第三方库存在差异），默认情况下， crypto++、pycryptodome、pyDes 即使 key、iv、编码 等等都一致的情况下，彼此所生成的密文是无法相互解密的。\n\n这直接导致了跨平台加解密非常麻烦。苦于目前网上并没有现成的跨平台加解密，故有了此工程。\n\n\n\u003e 其实各个语言的实现都不尽相同，例如在数据本身已对齐 BLOCKSIZE 的情况下会不会再填充一个 BLOCK ，IV 是否强制使用随机等。\n\n\n## 0x10 环境说明\n\n![](https://img.shields.io/badge/MSVC%20%20-14.3-green.svg) ![](https://img.shields.io/badge/Python-3.10-red.svg)\n\n\n## 0x20 核心文件\n\n### 0x21 C++\n\n- AES（依赖 [crypto++](./cpp/cryptopp/)）:\n    - [aes_crypto.hpp](./cpp/aes_crypto.hpp)\n    - [aes_crypto.cpp](./cpp/aes_crypto.cpp)\n- DES（依赖 [crypto++](./cpp/cryptopp/)）:\n    - [des_crypto.hpp](./cpp/des_crypto.hpp)\n    - [des_crypto.cpp](./cpp/des_crypto.cpp)\n- 测试：\n    - [test_crypto.cpp](./cpp/test_crypto.cpp)\n    - 只是 C++ 内部测试，想验证跨平台需要手动把 python 的密文拷贝到 [test_crypto.cpp](./cpp/test_crypto.cpp) 中替换验证\n\n\u003e 使用 VS2022 打开 [cpp.sln](./cpp/cpp.sln) 工程，默认就是已配置好 crypto++ 的依赖，若希望自行配置，可参考《[Visual Studio 搭建 Boost + CryptoPP 开发环境](https://exp-blog.com/lang/vs-da-jian-boostcryptopp-kai-fa-huan-jing/)》\n\n\n### 0x22 python\n\n- AES（依赖 [pycryptodome](https://pypi.org/project/pycryptodome/)）:\n    - [aes_crypto.py](./python/aes_crypto.py)\n- DES（依赖 [pyDes](https://pypi.org/project/pyDes/)）:\n    - [des_crypto.py](./python/des_crypto.py)\n- 测试: `cd python` \n    - 安装依赖: `python -m pip install -r requirements.txt`\n    - 执行命令: `python ./test/test_crypto.py`\n    - 只是 python 内部测试，想验证跨平台需要手动把 C++ 的密文拷贝到 [test_crypto.py](./python/test/test_crypto.py) 中替换验证\n\n\n\n## 0x30 开发环境部署\n\npython 环境直接安装就好， Windows 和 Mac 都是一样的。\n\n主要说一下 C++ 的环境：\n\n- Windows（需要提前安装 VS2022）: \n  - GUI 方法： 使用 VS2022 打开 [cpp.sln](./cpp/cpp.sln) 文件即可\n  - CMD 方法：\n    1. `cd cpp`\n    2. 编译: `bin/build.ps1`\n    3. 执行: `bin/run.ps1`\n- Mac/Linux (需要提前安装 g++ 和 cmake): \n    1. `cd cpp`\n    2. 编译: `bin/build.sh`\n    3. 执行: `bin/run.sh`\n\n![](./imgs/test_demo.jpg)\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fexp-codes%2Fpyc-cross-crypto","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fexp-codes%2Fpyc-cross-crypto","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fexp-codes%2Fpyc-cross-crypto/lists"}