{"id":16105102,"url":"https://github.com/intgr/pyaes","last_synced_at":"2025-04-06T02:32:51.456Z","repository":{"id":139071128,"uuid":"261891214","full_name":"intgr/pyaes","owner":"intgr","description":"AES implementation in pure Python using the PEP 272 cipher API. The goal of this module is to be as fast as reasonable in Python while still being Pythonic and readable/understandable. It is licensed under the permissive MIT license.","archived":false,"fork":false,"pushed_at":"2020-05-06T23:45:07.000Z","size":141,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-12T08:39:57.902Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/intgr.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":"2020-05-06T22:19:50.000Z","updated_at":"2020-05-06T23:45:09.000Z","dependencies_parsed_at":null,"dependency_job_id":"b19b673f-ea0e-4205-b953-2bbe6eda1e87","html_url":"https://github.com/intgr/pyaes","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/intgr%2Fpyaes","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/intgr%2Fpyaes/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/intgr%2Fpyaes/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/intgr%2Fpyaes/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/intgr","download_url":"https://codeload.github.com/intgr/pyaes/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247425765,"owners_count":20937010,"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":[],"created_at":"2024-10-09T19:08:26.427Z","updated_at":"2025-04-06T02:32:51.432Z","avatar_url":"https://github.com/intgr.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## pyaes is:\n\n* **an implementation of AES** (Advanced Encryption Standard) cipher in **pure Python**, including ECB \u0026 CBC modes\n* **easy to use:** it has a simple [PEP 272 cipher API](https://www.python.org/dev/peps/pep-0272/), like PyCrypto\n* **not too slow:** it's as fast as Python permits without obfuscating the code\n* **well-tested:** it includes a test runner to check the operation against NIST published test vectors\n* **raw cipher only:** it does not do padding/verification/key derivation -- any secure crypto protocol should\n* **liberal:** Licensed under the [permissive MIT license](https://opensource.org/licenses/MIT)\n\n### Show me the code!\n\n**[View in browser](./pyaes.py)**\n\n### How?\n\n```python\n\u003e\u003e\u003e import pyaes\n\u003e\u003e\u003e cryptor = pyaes.new('secret_secretkey', pyaes.MODE_CBC, IV='_some_random_iv_')\n\u003e\u003e\u003e ciphertext = cryptor.encrypt('This is a test! What could possibly go wrong?___')\n\u003e\u003e\u003e ciphertext\n'S8\\n\\x81\\xee3\\x86\\xd6\\t\\xf8\\xc6\\xde~\\xdc\\x14H#\\xd2\\xe1\\xda\\xd79\\x81\\xb7'\n'\u003e\\xdd\\xed\\xaa\\xed\\xcfp\\xee\\xc6\\x8f(\\xdc\\xb1A\"\\xe9[\\x9f{\\x8e\\xa6F\\xfbQ'\n\u003e\u003e\u003e decryptor = pyaes.new('secret_secretkey', pyaes.MODE_CBC, IV='_some_random_iv_')\n\u003e\u003e\u003e decryptor.decrypt(ciphertext)\n'This is a test! What could possibly go wrong?___'\n```\n\n### Caveats\n\nPlease beware that the nature of Python makes cryptography susceptible to\n[timing attacks](https://en.wikipedia.org/wiki/Timing_attack). Python (and\nother interpreted languages) introduce lots of data-dependent branches and have\na higher cache footprint than native code. Their general slowness also makes it\neasier to measure timing variations. **When in doubt, always use native code\ncryptography like [pycryptodome](https://www.pycryptodome.org/)**.\n\n### Why?\n\nThe main motivation for writing this was to provide the\n[PyPy project](https://www.pypy.org/) with a crypto benchmark for\n[speed.pypy.org](https://speed.pypy.org/).\n\nI was looking at the [SlowAES project](https://code.google.com/archive/p/slowaes/)\nfirst; it was very slow, so I created an optimization branch of it. However, I\nstill wasn't happy with the way the code was written. Its legacy as C code that\nwas converted to JavaScript, then converted to Python, was showing. The API was\nalso weird by Python standards.\n\nSo pyaes was born! Written from scratch to be Pythonic and benchmark-quality.\n\n### Speed\n\nEven though pyaes is an optimized Python implementation, Python itself is still slow. It should be capable of around **80 kB/s** on modern hardware; that's **1000x slower** than pure C implementations.\n\nIf you have any ideas how to make it faster, I'm interested in hearing your thoughts. :)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fintgr%2Fpyaes","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fintgr%2Fpyaes","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fintgr%2Fpyaes/lists"}