Name | RealCrypto JSON |
Version |
0.1.0
JSON |
| download |
home_page | None |
Summary | python version of rsa |
upload_time | 2024-11-25 14:30:48 |
maintainer | None |
docs_url | None |
author | zkh |
requires_python | <4.0,>=3.8 |
license | MIT License |
keywords |
cryto
openssl
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# Python 实现RSA、AES加解密
项目立意是为了解除python多数库只能使用公钥加密的限制。
## 示例
### RSA加解密
```python
from RealCrypto import Rsa
pyrsa = Rsa()
pub_key = """
-----BEGIN RSA PUBLIC KEY-----
xxxxxxxxxxxxxxxxxxxxxxxxxxxx
-----END RSA PUBLIC KEY-----
"""
data = "1bff1dfb66a599777dfe4d5edad268d41866e8f82d9604d6b750e2106b292cf2e11690420f515c3fe06d5fe851dc977e1eb3f0f610881659cb8fbf78e3e0dbc260dd7876146fc2b0e24a059fdf4d9540e8b1f9f755006085f491980248c345da03ff50edb77561bc5a304dc9ab658540cfbed4ebf828a351058abe7af508d5a19fa8dce65955d4f535618cba8fa115454fac166bf53784d51f319a56e3de071d766bda8c1683a74f10c9ee873daa710d233b53bcf8cbf7e0f9e48c13d9a1096ee3971c7c35b1b4bf4a4c6cdb4518c75147d5a21ed17fe161075baad4512ab3d4cf994f1bd5ca983fbf255f65b6a5d321ed68999cbff9b7e1b5dc9fc358d7a247"
ret = pyrsa.pub_decrypt(bytes.fromhex(data), pub_key)
print(ret)
ret = pyrsa.pub_encrypt("23342321",pub_key)
print(ret)
```
### AES加解密
```python
from RealCrypto import Aes,AesType
pyaes = Aes()
key = "1234657887654321"
iv = "1236547896325418"
plaintext = "just a test"
ret = pyaes.encrypt(plaintext,AesType.evp_aes_128_cbc, key,iv)
ret = pyaes.decrypt(ret,AesType.evp_aes_128_cbc, key,iv)
assert plaintext,ret.decode("utf-8")
```
### Hash算法
```python
teststr = "just a test"
# 字符串hash
ret = hash.md5(teststr)
print(ret.hex())
ret = hash.sha256(teststr)
print(ret.hex())
filepath = "test.txt"
# 文件hash
ret = hash.md5withfile(filepath)
print(ret.hex())
ret = hash.sha256withfile(filepath)
print(ret.hex())
```
Raw data
{
"_id": null,
"home_page": null,
"name": "RealCrypto",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.8",
"maintainer_email": null,
"keywords": "cryto, openssl",
"author": "zkh",
"author_email": "404937333@qq.com",
"download_url": "https://files.pythonhosted.org/packages/af/7b/52e0b9eba36dc2d4aff523dbac75fc39b3af6bcfe503dcfe78aaf56fa86a/realcrypto-0.1.0.tar.gz",
"platform": "Windows",
"description": "# Python \u5b9e\u73b0RSA\u3001AES\u52a0\u89e3\u5bc6\n\n\u9879\u76ee\u7acb\u610f\u662f\u4e3a\u4e86\u89e3\u9664python\u591a\u6570\u5e93\u53ea\u80fd\u4f7f\u7528\u516c\u94a5\u52a0\u5bc6\u7684\u9650\u5236\u3002\n\n\n\n## \u793a\u4f8b\n\n\n### RSA\u52a0\u89e3\u5bc6\n```python\nfrom RealCrypto import Rsa\n\n\npyrsa = Rsa()\n\npub_key = \"\"\"\n-----BEGIN RSA PUBLIC KEY-----\nxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n-----END RSA PUBLIC KEY-----\n\"\"\"\n\ndata = \"1bff1dfb66a599777dfe4d5edad268d41866e8f82d9604d6b750e2106b292cf2e11690420f515c3fe06d5fe851dc977e1eb3f0f610881659cb8fbf78e3e0dbc260dd7876146fc2b0e24a059fdf4d9540e8b1f9f755006085f491980248c345da03ff50edb77561bc5a304dc9ab658540cfbed4ebf828a351058abe7af508d5a19fa8dce65955d4f535618cba8fa115454fac166bf53784d51f319a56e3de071d766bda8c1683a74f10c9ee873daa710d233b53bcf8cbf7e0f9e48c13d9a1096ee3971c7c35b1b4bf4a4c6cdb4518c75147d5a21ed17fe161075baad4512ab3d4cf994f1bd5ca983fbf255f65b6a5d321ed68999cbff9b7e1b5dc9fc358d7a247\"\n\nret = pyrsa.pub_decrypt(bytes.fromhex(data), pub_key)\nprint(ret)\n\nret = pyrsa.pub_encrypt(\"23342321\",pub_key)\nprint(ret)\n```\n\n\n### AES\u52a0\u89e3\u5bc6\n```python\nfrom RealCrypto import Aes,AesType\n\npyaes = Aes()\n\nkey = \"1234657887654321\"\niv = \"1236547896325418\"\nplaintext = \"just a test\"\nret = pyaes.encrypt(plaintext,AesType.evp_aes_128_cbc, key,iv)\nret = pyaes.decrypt(ret,AesType.evp_aes_128_cbc, key,iv)\nassert plaintext,ret.decode(\"utf-8\")\n\n```\n\n\n### Hash\u7b97\u6cd5\n\n```python\nteststr = \"just a test\"\n\n# \u5b57\u7b26\u4e32hash\nret = hash.md5(teststr)\nprint(ret.hex())\n\nret = hash.sha256(teststr)\nprint(ret.hex())\n\n\nfilepath = \"test.txt\"\n# \u6587\u4ef6hash\nret = hash.md5withfile(filepath)\nprint(ret.hex())\n\nret = hash.sha256withfile(filepath)\nprint(ret.hex())\n```\n",
"bugtrack_url": null,
"license": "MIT License",
"summary": "python version of rsa",
"version": "0.1.0",
"project_urls": null,
"split_keywords": [
"cryto",
" openssl"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "0b6204a3e9491610f1d944ee2d278890ad5a4c7e5eedfa410a67d467fe8d0edf",
"md5": "ba6f19db5d252f92257ce1bdc5d1038c",
"sha256": "9696353745ebaad87607d0d62ed0054c060ece3423d68c678b9cd673a4f6a77c"
},
"downloads": -1,
"filename": "RealCrypto-0.1.0-cp310-cp310-manylinux_2_28_x86_64.whl",
"has_sig": false,
"md5_digest": "ba6f19db5d252f92257ce1bdc5d1038c",
"packagetype": "bdist_wheel",
"python_version": "cp310",
"requires_python": "<4.0,>=3.8",
"size": 2372202,
"upload_time": "2024-11-25T14:30:30",
"upload_time_iso_8601": "2024-11-25T14:30:30.658817Z",
"url": "https://files.pythonhosted.org/packages/0b/62/04a3e9491610f1d944ee2d278890ad5a4c7e5eedfa410a67d467fe8d0edf/RealCrypto-0.1.0-cp310-cp310-manylinux_2_28_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "0c49bdd9da863565daa72fb4b117a651d838c65c05d466f67367f429e421bbf7",
"md5": "bdc7902b964dfb3f722695edd78fa9a1",
"sha256": "f4d1154b59ee4af41c7c579bb577ac7d1811af8bc3f75cf015f4e4ef4d0416f6"
},
"downloads": -1,
"filename": "RealCrypto-0.1.0-cp310-cp310-win_amd64.whl",
"has_sig": false,
"md5_digest": "bdc7902b964dfb3f722695edd78fa9a1",
"packagetype": "bdist_wheel",
"python_version": "cp310",
"requires_python": "<4.0,>=3.8",
"size": 45757,
"upload_time": "2024-11-25T14:30:32",
"upload_time_iso_8601": "2024-11-25T14:30:32.785325Z",
"url": "https://files.pythonhosted.org/packages/0c/49/bdd9da863565daa72fb4b117a651d838c65c05d466f67367f429e421bbf7/RealCrypto-0.1.0-cp310-cp310-win_amd64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "9298d173ecad51649a34d7ab3af93783aebb0b9602d503ad27f82e2d714bb7a1",
"md5": "877d208f0cb4770a4ed187f5ba34f6fd",
"sha256": "8fb2ec8d7d604e568abd11377ff88b0754a919c7f3760d649848ec703203a666"
},
"downloads": -1,
"filename": "RealCrypto-0.1.0-cp311-cp311-manylinux_2_28_x86_64.whl",
"has_sig": false,
"md5_digest": "877d208f0cb4770a4ed187f5ba34f6fd",
"packagetype": "bdist_wheel",
"python_version": "cp311",
"requires_python": "<4.0,>=3.8",
"size": 2372289,
"upload_time": "2024-11-25T14:30:34",
"upload_time_iso_8601": "2024-11-25T14:30:34.402616Z",
"url": "https://files.pythonhosted.org/packages/92/98/d173ecad51649a34d7ab3af93783aebb0b9602d503ad27f82e2d714bb7a1/RealCrypto-0.1.0-cp311-cp311-manylinux_2_28_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "b10c9ca1bd89a2766f27992c40a6dbe8526749bb7a10bcb429b948f30d661bc1",
"md5": "88e202ee23d0f61a643f2778a7904253",
"sha256": "3732670fb87ce68e071797d6147074806d4e528cb67cc31420c53708ae01519a"
},
"downloads": -1,
"filename": "RealCrypto-0.1.0-cp311-cp311-win_amd64.whl",
"has_sig": false,
"md5_digest": "88e202ee23d0f61a643f2778a7904253",
"packagetype": "bdist_wheel",
"python_version": "cp311",
"requires_python": "<4.0,>=3.8",
"size": 45695,
"upload_time": "2024-11-25T14:30:36",
"upload_time_iso_8601": "2024-11-25T14:30:36.074094Z",
"url": "https://files.pythonhosted.org/packages/b1/0c/9ca1bd89a2766f27992c40a6dbe8526749bb7a10bcb429b948f30d661bc1/RealCrypto-0.1.0-cp311-cp311-win_amd64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "f96657a6a486ccdb141f9acd85afc02aa703abc437c759cc5f93ecea474a9ac5",
"md5": "b7d89f09503a88dd88c7d04d93ef2c5a",
"sha256": "15f35ca95c01a888376a0b51a2fe435389f042b2d725002b325b29369f3979ab"
},
"downloads": -1,
"filename": "RealCrypto-0.1.0-cp312-cp312-manylinux_2_28_x86_64.whl",
"has_sig": false,
"md5_digest": "b7d89f09503a88dd88c7d04d93ef2c5a",
"packagetype": "bdist_wheel",
"python_version": "cp312",
"requires_python": "<4.0,>=3.8",
"size": 2372086,
"upload_time": "2024-11-25T14:30:37",
"upload_time_iso_8601": "2024-11-25T14:30:37.627308Z",
"url": "https://files.pythonhosted.org/packages/f9/66/57a6a486ccdb141f9acd85afc02aa703abc437c759cc5f93ecea474a9ac5/RealCrypto-0.1.0-cp312-cp312-manylinux_2_28_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "fbb910cfb02d2c269275dc810d127134d0d8b85711f647c2a73394cdd062b4b5",
"md5": "c6e752b9a76812b07e2e8d1eb6138a57",
"sha256": "d73d5a65f0d09b60009119d2673417c4ee67ae0ce773881c84f08e0dac6da751"
},
"downloads": -1,
"filename": "RealCrypto-0.1.0-cp312-cp312-win_amd64.whl",
"has_sig": false,
"md5_digest": "c6e752b9a76812b07e2e8d1eb6138a57",
"packagetype": "bdist_wheel",
"python_version": "cp312",
"requires_python": "<4.0,>=3.8",
"size": 45681,
"upload_time": "2024-11-25T14:30:38",
"upload_time_iso_8601": "2024-11-25T14:30:38.999828Z",
"url": "https://files.pythonhosted.org/packages/fb/b9/10cfb02d2c269275dc810d127134d0d8b85711f647c2a73394cdd062b4b5/RealCrypto-0.1.0-cp312-cp312-win_amd64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "91d24b9555ca8affa3b9e95e06550bbb5043ccbe3d17cf1d3cee8478174271db",
"md5": "8f7d7611186ac6f7c1f43ca010766da2",
"sha256": "c034e253af1275fc2c67340a80095aeaa916aabd3aecbd970ef8f43a3adb64c5"
},
"downloads": -1,
"filename": "RealCrypto-0.1.0-cp38-cp38-manylinux_2_28_x86_64.whl",
"has_sig": false,
"md5_digest": "8f7d7611186ac6f7c1f43ca010766da2",
"packagetype": "bdist_wheel",
"python_version": "cp38",
"requires_python": "<4.0,>=3.8",
"size": 2667038,
"upload_time": "2024-11-25T14:30:41",
"upload_time_iso_8601": "2024-11-25T14:30:41.736871Z",
"url": "https://files.pythonhosted.org/packages/91/d2/4b9555ca8affa3b9e95e06550bbb5043ccbe3d17cf1d3cee8478174271db/RealCrypto-0.1.0-cp38-cp38-manylinux_2_28_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "c09de9153363d071e03b873f6917be6287256e70a018c0c303a5f2bc2b7ee52e",
"md5": "222bc1ae3e0b5ad3fc3c93d5f4ef8546",
"sha256": "510a364b2675cd7246864654a79cb9c5b754dc46fffcf04dc9d0e75d9191154e"
},
"downloads": -1,
"filename": "RealCrypto-0.1.0-cp38-cp38-win_amd64.whl",
"has_sig": false,
"md5_digest": "222bc1ae3e0b5ad3fc3c93d5f4ef8546",
"packagetype": "bdist_wheel",
"python_version": "cp38",
"requires_python": "<4.0,>=3.8",
"size": 46537,
"upload_time": "2024-11-25T14:30:44",
"upload_time_iso_8601": "2024-11-25T14:30:44.285365Z",
"url": "https://files.pythonhosted.org/packages/c0/9d/e9153363d071e03b873f6917be6287256e70a018c0c303a5f2bc2b7ee52e/RealCrypto-0.1.0-cp38-cp38-win_amd64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "3999d3320c914347c638ad452c02e5bb19d98ece88dcb8ac3b1bd1e707a2286a",
"md5": "47877ce61c30f46bf8ec66ca93b57d83",
"sha256": "91527398b5096e166a975627a264dbcf9035a5f11ffa28c3c6e98c5ec71f5dc4"
},
"downloads": -1,
"filename": "RealCrypto-0.1.0-cp39-cp39-manylinux_2_28_x86_64.whl",
"has_sig": false,
"md5_digest": "47877ce61c30f46bf8ec66ca93b57d83",
"packagetype": "bdist_wheel",
"python_version": "cp39",
"requires_python": "<4.0,>=3.8",
"size": 2372749,
"upload_time": "2024-11-25T14:30:45",
"upload_time_iso_8601": "2024-11-25T14:30:45.930549Z",
"url": "https://files.pythonhosted.org/packages/39/99/d3320c914347c638ad452c02e5bb19d98ece88dcb8ac3b1bd1e707a2286a/RealCrypto-0.1.0-cp39-cp39-manylinux_2_28_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "cccbea191756b6eb08fb79333d1fce2dd797467056f5d2e0aeccc042bc8dc811",
"md5": "72c7803eab834693d95f0d86fe74c18c",
"sha256": "fe252d01fb91349ad52e51355da137e7af35669957bc98fd60e30172072ef5ea"
},
"downloads": -1,
"filename": "RealCrypto-0.1.0-cp39-cp39-win_amd64.whl",
"has_sig": false,
"md5_digest": "72c7803eab834693d95f0d86fe74c18c",
"packagetype": "bdist_wheel",
"python_version": "cp39",
"requires_python": "<4.0,>=3.8",
"size": 46248,
"upload_time": "2024-11-25T14:30:47",
"upload_time_iso_8601": "2024-11-25T14:30:47.314826Z",
"url": "https://files.pythonhosted.org/packages/cc/cb/ea191756b6eb08fb79333d1fce2dd797467056f5d2e0aeccc042bc8dc811/RealCrypto-0.1.0-cp39-cp39-win_amd64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "af7b52e0b9eba36dc2d4aff523dbac75fc39b3af6bcfe503dcfe78aaf56fa86a",
"md5": "cdaf247fb82d7d963b0b6c89651bc37d",
"sha256": "6425ca6e7d098a6575271bce31d6b92bdb1d70ddf162f953aeeb9b1a30ef5d89"
},
"downloads": -1,
"filename": "realcrypto-0.1.0.tar.gz",
"has_sig": false,
"md5_digest": "cdaf247fb82d7d963b0b6c89651bc37d",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.8",
"size": 77092,
"upload_time": "2024-11-25T14:30:48",
"upload_time_iso_8601": "2024-11-25T14:30:48.384795Z",
"url": "https://files.pythonhosted.org/packages/af/7b/52e0b9eba36dc2d4aff523dbac75fc39b3af6bcfe503dcfe78aaf56fa86a/realcrypto-0.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-25 14:30:48",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "realcrypto"
}