{"id":26355721,"url":"https://github.com/marcobellaccini/pyaescrypt","last_synced_at":"2025-04-06T16:10:11.951Z","repository":{"id":43791885,"uuid":"78934432","full_name":"marcobellaccini/pyAesCrypt","owner":"marcobellaccini","description":"A Python 3 module and script that uses AES256-CBC to encrypt/decrypt files and streams in AES Crypt file format (version 2).","archived":false,"fork":false,"pushed_at":"2023-11-11T11:21:51.000Z","size":86,"stargazers_count":235,"open_issues_count":0,"forks_count":50,"subscribers_count":13,"default_branch":"master","last_synced_at":"2025-04-06T16:10:02.405Z","etag":null,"topics":["aes","aes-256","aes-encryption","cryptography","python3","security"],"latest_commit_sha":null,"homepage":"","language":"Python","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/marcobellaccini.png","metadata":{"files":{"readme":"README.rst","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":"2017-01-14T10:43:49.000Z","updated_at":"2024-12-23T08:12:07.000Z","dependencies_parsed_at":"2024-06-18T15:40:43.867Z","dependency_job_id":null,"html_url":"https://github.com/marcobellaccini/pyAesCrypt","commit_stats":{"total_commits":52,"total_committers":6,"mean_commits":8.666666666666666,"dds":0.3653846153846154,"last_synced_commit":"2448d3a3384959e49cf6071b1b9f6a6d8ee6b4f6"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcobellaccini%2FpyAesCrypt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcobellaccini%2FpyAesCrypt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcobellaccini%2FpyAesCrypt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcobellaccini%2FpyAesCrypt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/marcobellaccini","download_url":"https://codeload.github.com/marcobellaccini/pyAesCrypt/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247509221,"owners_count":20950232,"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","aes-256","aes-encryption","cryptography","python3","security"],"created_at":"2025-03-16T13:17:31.825Z","updated_at":"2025-04-06T16:10:11.917Z","avatar_url":"https://github.com/marcobellaccini.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"pyAesCrypt\n===============\n.. image:: https://github.com/marcobellaccini/pyaescrypt/actions/workflows/main.yml/badge.svg\n    :target: https://github.com/marcobellaccini/pyAesCrypt/actions\n.. image:: https://pepy.tech/badge/pyaescrypt\n    :target: https://pepy.tech/project/pyaescrypt\n\nAbout pyAesCrypt\n--------------------------\npyAesCrypt is a Python 3 file-encryption module and script that uses AES256-CBC to encrypt/decrypt files and binary streams.\n\npyAesCrypt is compatible with the `AES Crypt`_ `file format`_ (version 2).\n\nIt is Free Software, released under the `Apache License, Version 2.0`_.\n\npyAesCrypt is brought to you by Marco Bellaccini - marco.bellaccini(at!)gmail.com.\n \nIMPORTANT SECURITY NOTE: version 2 of the AES Crypt file format does not authenticate the \"file size modulo 16\" byte. This implies that an attacker  \nwith write access to the encrypted file may alter the corresponding plaintext file size by up to 15 bytes.\n\nNOTE: there is no low-level memory management in Python, hence it is not possible to wipe memory areas were sensitive information was stored.\n\nModule usage example\n------------------------\nHere is an example showing encryption and decryption of a file:\n\n.. code:: python\n\n    import pyAesCrypt\n    password = \"please-use-a-long-and-random-password\"\n    # encrypt\n    pyAesCrypt.encryptFile(\"data.txt\", \"data.txt.aes\", password)\n    # decrypt\n    pyAesCrypt.decryptFile(\"data.txt.aes\", \"dataout.txt\", password)\n\n**This is the most straightforward way to use pyAesCrypt, and should be preferred.**\n\nIf you need to specify a custom buffer size (default is 64KB), you can pass it as an optional argument:\n\n.. code:: python\n\n    import pyAesCrypt\n    # custom encryption/decryption buffer size (default is 64KB)\n    bufferSize = 128 * 1024\n    password = \"please-use-a-long-and-random-password\"\n    # encrypt\n    pyAesCrypt.encryptFile(\"data.txt\", \"data.txt.aes\", password, bufferSize)\n    # decrypt\n    pyAesCrypt.decryptFile(\"data.txt.aes\", \"dataout.txt\", password, bufferSize)\n\nIn case you need it, you can work with binary streams too:\n\n.. code:: python\n\n    import pyAesCrypt\n    from os import stat, remove\n    # encryption/decryption buffer size - 64K\n    # with stream-oriented functions, setting buffer size is mandatory\n    bufferSize = 64 * 1024\n    password = \"please-use-a-long-and-random-password\"\n    \n    # encrypt\n    with open(\"data.txt\", \"rb\") as fIn:\n        with open(\"data.txt.aes\", \"wb\") as fOut:\n            pyAesCrypt.encryptStream(fIn, fOut, password, bufferSize)\n    \n    # decrypt\n    with open(\"data.txt.aes\", \"rb\") as fIn:\n        try:\n            with open(\"dataout.txt\", \"wb\") as fOut:\n                # decrypt file stream\n                pyAesCrypt.decryptStream(fIn, fOut, password, bufferSize)\n        except ValueError:\n            # remove output file on error\n            remove(\"dataout.txt\")\n\nyou can also perform in-memory encryption/decryption (using BytesIO):\n\n.. code:: python\n\n    import pyAesCrypt\n    import io\n    \n    bufferSize = 64 * 1024\n    password = \"please-use-a-long-and-random-password\"\n    \n    # binary data to be encrypted\n    pbdata = b\"This is binary plaintext \\x00\\x01\"\n    \n    # input plaintext binary stream\n    fIn = io.BytesIO(pbdata)\n    \n    # initialize ciphertext binary stream\n    fCiph = io.BytesIO()\n    \n    # initialize decrypted binary stream\n    fDec = io.BytesIO()\n    \n    # encrypt stream\n    pyAesCrypt.encryptStream(fIn, fCiph, password, bufferSize)\n    \n    # print encrypted data\n    print(\"This is the ciphertext:\\n\" + str(fCiph.getvalue()))\n    \n    # go back to the start of the ciphertext stream\n    fCiph.seek(0)\n    \n    # decrypt stream\n    pyAesCrypt.decryptStream(fCiph, fDec, password, bufferSize)\n    \n    # print decrypted data\n    print(\"Decrypted data:\\n\" + str(fDec.getvalue()))\n\n\n\nScript usage examples\n------------------------\nEncrypt file test.txt in test.txt.aes:\n\n\tpyAesCrypt -e test.txt\n\nDecrypt file test.txt.aes in test.txt:\n\n\tpyAesCrypt -d test.txt.aes\n\t\nEncrypt file test.txt in test2.txt.aes:\n\n\tpyAesCrypt -e test.txt -o test2.txt.aes\n\nDecrypt file test.txt.aes in test2.txt:\n\n\tpyAesCrypt -d test.txt.aes -o test2.txt\n\nFAQs\n------------------------\n- *Is pyAesCrypt malware?*\n\n  **NO!** Of course it isn't!\n\n  Nevertheless, being a module, it can be used by any other software, including malware.\n  \n  In fact, it has been reported that it is used as crypto library by some ransomware.\n\n.. _AES Crypt: https://www.aescrypt.com\n.. _file format: https://www.aescrypt.com/aes_file_format.html\n.. _Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcobellaccini%2Fpyaescrypt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarcobellaccini%2Fpyaescrypt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcobellaccini%2Fpyaescrypt/lists"}