{"id":20566265,"url":"https://github.com/telkomdev/pycrypsi","last_synced_at":"2025-03-06T08:47:22.924Z","repository":{"id":64707814,"uuid":"566919610","full_name":"telkomdev/pycrypsi","owner":"telkomdev","description":"Python custom crypto utility that wraps the pycryptodome module to make life easier (Digest, Cipher, HMAC, RSA, RSA Digital Signature)","archived":false,"fork":false,"pushed_at":"2023-01-23T11:56:54.000Z","size":355,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-16T20:19:12.607Z","etag":null,"topics":["cryptography","hash","python","rsa","telkomdev"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/telkomdev.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}},"created_at":"2022-11-16T17:32:55.000Z","updated_at":"2022-11-29T07:21:58.000Z","dependencies_parsed_at":"2023-02-12T23:00:50.246Z","dependency_job_id":null,"html_url":"https://github.com/telkomdev/pycrypsi","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/telkomdev%2Fpycrypsi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/telkomdev%2Fpycrypsi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/telkomdev%2Fpycrypsi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/telkomdev%2Fpycrypsi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/telkomdev","download_url":"https://codeload.github.com/telkomdev/pycrypsi/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242179259,"owners_count":20084940,"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":["cryptography","hash","python","rsa","telkomdev"],"created_at":"2024-11-16T04:40:49.775Z","updated_at":"2025-03-06T08:47:22.893Z","avatar_url":"https://github.com/telkomdev.png","language":"Python","readme":"## pycrypsi (Python Crypto Utility)\n\nCustom crypto utility that wraps the `pycryptodome` module to make life easier\n\n[![pycrypsi CI](https://github.com/telkomdev/pycrypsi/actions/workflows/ci.yml/badge.svg)](https://github.com/telkomdev/pycrypsi/actions/workflows/ci.yml)\n\n### pycrypsi is compatible with each other with the following libraries\n- NodeJs https://github.com/telkomdev/crypsi\n- Golang https://github.com/telkomdev/go-crypsi\n- C# (.NET) https://github.com/telkomdev/NetCrypsi\n- Java/JVM https://github.com/telkomdev/jcrypsi\n- Javascript (React and Browser) https://github.com/telkomdev/crypsi.js\n\n### Features\n- Asymmetric encryption with RSA\n- Generate RSA private and public key\n- Digital Signature with RSA private and public key using PSS\n- Symmetric encryption with AES\n- Message authentication code with HMAC\n- Generate Hash with Common DIGEST Algorithm\n\n### Usage\n\nGenerate RSA Private and Public key\n```python\nfrom pycrypsi import (\n    rsa\n)\n\nimport os\n\nBASE_DIR = os.path.dirname(os.path.abspath(__file__))\n\ndef main():\n    private_key, public_key, private_key_b64, public_key_b64 = rsa.generate_key_pairs(rsa.KEY_SIZE_2KB)\n    print(private_key.decode())\n    print(public_key.decode())\n    print()\n    print(private_key_b64.decode())\n    print()\n    print(public_key_b64.decode())\n\n    with open('private.key', 'wb') as private_key_writer:\n        private_key_writer.write(private_key)\n    \n    with open('public.key', 'wb') as public_key_writer:\n        public_key_writer.write(public_key)\n\nif __name__ == \"__main__\":\n    main()\n```\n\nGenerate `HASH` with common `Digest Algorithm`\n```python\nfrom pycrypsi import (\n    digest\n)\n\nimport os\n\nBASE_DIR = os.path.dirname(os.path.abspath(__file__))\n\ndef main():\n    print(digest.md5_hex(b'wuriyanto'))\n    print(digest.sha1_hex(b'wuriyanto', b'alex'))\n    print(digest.sha1_hex(b'wuriyanto', b'alex', b'bobby'))\n\n    print(digest.sha256_hex(b'wuriyanto'))\n    print(digest.sha384_hex(b'wuriyanto'))\n    print(digest.sha512_hex(b'wuriyanto'))\n\n    data = 'wuriyanto'\n    print(digest.sha256_hex(bytes(data, 'utf-8')))\n\n    # get Hash value from file\n\n    with open(os.path.join(BASE_DIR, 'tests', 'testdata', 'gopher.png'), 'rb') as input_file:\n        hash_val = digest.sha256_hex(input_file.read())\n        print(hash_val)\n        \nif __name__ == \"__main__\":\n    main()\n```\n\nData and File Encryption with AES\n```python\nfrom pycrypsi import (\n    aes\n)\n\nimport os\n\nBASE_DIR = os.path.dirname(os.path.abspath(__file__))\n\ndef main():\n    key256 = \"abc$#128djdyAgbjau\u0026YAnmcbagryt5x\"\n\n    data = 'wuriyanto'\n\n    res_data_encrypted = aes.encrypt_with_aes256_cbc_hex(bytes(key256, 'utf-8'), bytes(data, 'utf-8'))\n    print(res_data_encrypted)\n\n    res_data_decrypted = aes.decrypt_with_aes256_cbc_hex(bytes(key256, 'utf-8'), res_data_encrypted)\n    print(res_data_decrypted.decode())\n\n    # encrypt and decrypt file\n    with open(os.path.join(BASE_DIR, 'tests', 'testdata', 'gopher.png'), 'rb') as input_file:\n        encrypted_file_data = aes.encrypt_with_aes256_cbc_hex(bytes(key256, 'utf-8'), input_file.read())\n        with open('out.bin', 'wb') as out_file:\n            out_file.write(encrypted_file_data.encode())\n    \n    with open('out.bin', 'rb') as input_file:\n        # print(input_file.read().decode())\n        decrypted_file_data = aes.decrypt_with_aes256_cbc_hex(bytes(key256, 'utf-8'), input_file.read().decode())\n        with open('out.png', 'wb') as out_file:\n            out_file.write(decrypted_file_data)\nif __name__ == \"__main__\":\n    main()\n```\n\nGenerate `HASH` with `HMAC (Hash-Based Message Authentication Codes)`\n```python\nfrom pycrypsi import (\n    hmac\n)\n\nimport os\n\nBASE_DIR = os.path.dirname(os.path.abspath(__file__))\n\ndef main():\n    key = 'abc$#128djdyAgbjau\u0026YAnmcbagryt5x'\n    print(hmac.md5_hex(bytes(key, 'utf-8'), b'wuriyanto'))\n    print(hmac.sha1_hex(bytes(key, 'utf-8'), b'wuriyanto', b'alex'))\n    print(hmac.sha1_hex(bytes(key, 'utf-8'), b'wuriyanto', b'alex', b'bobby'))\n\n    print(hmac.sha256_hex(bytes(key, 'utf-8'), b'wuriyanto'))\n    print(hmac.sha384_hex(bytes(key, 'utf-8'), b'wuriyanto'))\n    print(hmac.sha512_hex(bytes(key, 'utf-8'), b'wuriyanto'))\n\n    data = 'wuriyanto'\n    print(hmac.sha256_hex(bytes(key, 'utf-8'), bytes(data, 'utf-8')))\n\n    # get Hash value from file\n\n    with open(os.path.join(BASE_DIR, 'tests', 'testdata', 'gopher.png'), 'rb') as input_file:\n        hash_val = hmac.sha256_hex(bytes(key, 'utf-8'), input_file.read())\n        print(hash_val)\n        \nif __name__ == \"__main__\":\n    main()\n```","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftelkomdev%2Fpycrypsi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftelkomdev%2Fpycrypsi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftelkomdev%2Fpycrypsi/lists"}