{ "info": { "author": "Jashandeep Sohi", "author_email": "jashandeep.s.sohi@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "Intended Audience :: Education", "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3 :: Only", "Topic :: Security :: Cryptography", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "blowfish\n========\nThis module implements the Blowfish cipher using only Python (3.4+).\n\nBlowfish is a block cipher that can be used for symmetric-key encryption. It\nhas a 8-byte block size and supports a variable-length key, from 4 to 56 bytes.\nIt's fast, free and has been analyzed considerably. It was designed by Bruce\nSchneier and more details about it can be found at\n.\n\n.. contents::\n :local:\n :backlinks: top\n\nDependencies\n------------\n- Python 3.4+\n\nFeatures\n--------\n- Fast (well, as fast you can possibly go using only Python 3.4+)\n- Efficient; generators/iterators are used liberally to reduce memory usage\n- Electronic Codebook (ECB) mode\n- Electronic Codebook with Ciphertext Stealing (ECB-CTS) mode\n- Cipher-Block Chaining (CBC) mode\n- Cipher-Block Chaining with Ciphertext Stealing (CBC-CTS) mode\n- Propagating Cipher-Block Chaining (PCBC) mode\n- Cipher Feedback (CFB) mode\n- Output Feedback (OFB) mode\n- Counter (CTR) mode\n\nInstallation\n------------\nIf you just need a Blowfish cipher in your Python project, feel free to\nmanually copy ``blowfish.py`` to your package directory (license permitting).\n\ndistutils\n#########\nTo install the module to your Python distribution, use the included\n`distutils` script::\n\n $ python setup.py install\n \npip\n####\nStable versions can be installed from `pypi`_ using `pip`::\n \n $ pip install blowfish\n \n`pip` can also install the latest development version directly from `git`::\n \n $ pip install 'git+https://github.com/jashandeep-sohi/python-blowfish.git'\n \n.. _pypi: https://pypi.python.org/pypi/blowfish\n\nDevelopment\n-----------\nWant to add a mode of operation? Speed up encryption?\n\nMake your changes to a clone of the repository at\nhttps://github.com/jashandeep-sohi/python-blowfish\nand send me a pull request.\n\nTests\n-----\nTests are written using the Python `unittest` framework. All tests are in the\n``test.py`` file and can be run using::\n \n $ python -m unittest test.py\n\n\nBugs\n----\nAre you having problems? Please let me know at\nhttps://github.com/jashandeep-sohi/python-blowfish/issues\n\nUsage\n-----\n.. warning::\n\n Cryptography is complex, so please don't use this module in anything\n *critical* without understanding what you are doing and checking the source\n code to make sure it is doing what you want it to.\n \n.. note::\n\n This is just a quick overview on how to use the module. For detailed\n documentation please see the `docstrings` in the module.\n\nFirst create a `Cipher` object with a `key`.\n\n.. code:: python3\n\n import blowfish\n \n cipher = blowfish.Cipher(b\"Key must be between 4 and 56 bytes long.\")\n \nBy default this initializes a Blowfish cipher that will interpret bytes using\nthe big-endian byte order. Should the need arrise to use the little-endian byte\norder, provide ``\"little\"`` as the second argument.\n\n.. code:: python3\n\n cipher_little = blowfish.Cipher(b\"my key\", byte_order = \"little\")\n \nBlock\n#####\nTo encrypt or decrypt a block of data (8 bytes), use the `encrypt_block` or\n`decrypt_block` methods of the `Cipher` object.\n\n.. code:: python3\n\n from os import urandom\n \n block = urandom(8)\n \n ciphertext = cipher.encrypt_block(block)\n plaintext = cipher.decrypt_block(ciphertext)\n \n assert block == plaintext\n \nAs these methods can only operate on 8 bytes of data, they're of little\npractical use. Instead, use one of the implemented modes of operation.\n \nElectronic Codebook Mode (ECB)\n##############################\nTo encrypt or decrypt data in ECB mode, use `encrypt_ecb` or `decrypt_ecb`\nmethods of the `Cipher` object. ECB mode can only operate on data that is a\nmultiple of the block-size in length.\n\n.. code:: python3\n\n data = urandom(10 * 8) # data to encrypt\n \n data_encrypted = b\"\".join(cipher.encrypt_ecb(data))\n data_decrypted = b\"\".join(cipher.decrypt_ecb(data_encrypted)\n \n assert data == data_decrypted\n \nElectronic Codebook Mode with Cipher Text Stealing (ECB-CTS)\n############################################################\nTo encrypt or decrypt data in ECB-CTS mode, use `encrypt_ecb_cts` or \n`decrypt_ebc_cts` methods of the `Cipher` object. ECB-CTS mode can operate\non data of any length greater than 8 bytes.\n\n.. code:: python3\n\n data = urandom(10 * 8 + 5) # data to encrypt\n \n data_encrypted = b\"\".join(cipher.encrypt_ecb_cts(data))\n data_decrypted = b\"\".join(cipher.decrypt_ecb_cts(data_encrypted))\n \n assert data == data_decrypted\n \nCipher-Block Chaining Mode (CBC)\n################################\nTo encrypt or decrypt data in CBC mode, use `encrypt_cbc` or `decrypt_cbc`\nmethods of the `Cipher` object. CBC mode can only operate on data that is a\nmultiple of the block-size in length.\n\n.. code:: python3\n\n data = urandom(10 * 8) # data to encrypt\n iv = urandom(8) # initialization vector\n \n data_encrypted = b\"\".join(cipher.encrypt_cbc(data, iv))\n data_decrypted = b\"\".join(cipher.decrypt_cbc(data_encrypted, iv))\n \n assert data == data_decrypted\n \nCipher-Block Chaining with Ciphertext Stealing (CBC-CTS)\n########################################################\nTo encrypt or decrypt data in CBC-CTS mode, use `encrypt_cbc_cts` or\n`decrypt_cbc_cts` methods of the `Cipher` object. CBC-CTS mode can operate\non data of any length greater than 8 bytes.\n\n.. code:: python3\n\n data = urandom(10 * 8 + 6) # data to encrypt\n iv = urandom(8) # initialization vector\n \n data_encrypted = b\"\".join(cipher.encrypt_cbc_cts(data, iv))\n data_decrypted = b\"\".join(cipher.decrypt_cbc_cts(data_encrypted, iv))\n \n assert data == data_decrypted\n\nPropagating Cipher-Block Chaining Mode (PCBC)\n#############################################\nTo encrypt or decrypt data in PCBC mode, use `encrypt_pcbc` or `decrypt_pcbc`\nmethods of the `Cipher` object. PCBC mode can only operate on data that is a\nmultiple of the block-size in length.\n\n.. code:: python3\n\n data = urandom(10 * 8) # data to encrypt\n iv = urandom(8) # initialization vector\n \n data_encrypted = b\"\".join(cipher.encrypt_pcbc(data, iv))\n data_decrypted = b\"\".join(cipher.decrypt_pcbc(data_encrypted, iv))\n \n assert data == data_decrypted\n\nCipher Feedback Mode (CFB)\n##########################\nTo encrypt or decrypt data in CFB mode, use `encrypt_cfb` or `decrypt_cfb`\nmethods of the `Cipher` object. CFB mode can operate on data of any length.\n\n.. code:: python3\n\n data = urandom(10 * 8 + 7) # data to encrypt\n iv = urandom(8) # initialization vector\n \n data_encrypted = b\"\".join(cipher.encrypt_cfb(data, iv))\n data_decrypted = b\"\".join(cipher.decrypt_cfb(data_encrypted, iv))\n \n assert data == data_decrypted\n\nOutput Feedback Mode (OFB)\n##########################\nTo encrypt or decrypt data in OFB mode, use `encrypt_ofb` or `decrypt_ofb`\nmethods of the `Cipher` object. OFB mode can operate on data of any length.\n\n.. code:: python3\n \n data = urandom(10 * 8 + 1) # data to encrypt\n iv = urandom(8) # initialization vector\n \n data_encrypted = b\"\".join(cipher.encrypt_ofb(data, iv))\n data_decrypted = b\"\".join(cipher.decrypt_ofb(data_encrypted, iv))\n \n assert data == data_decrypted\n\nCounter Mode (CTR)\n##################\nTo encrypt or decrypt data in CTR mode, use `encrypt_ctr` or `decrypt_ctr`\nmethods of the `Cipher` object. CTR mode can operate on data of any length.\nAlthough you can use any `counter` you want, a simple increment by one counter\nis secure and the most popular. So for convenience sake a simple increment by\none counter is implemented by the `blowfish.ctr_counter` function. However,\nyou should implement your own for optimization purposes.\n\n.. code:: python3\n\n from operator import xor\n \n data = urandom(10 * 8 + 2) # data to encrypt\n \n # increment by one counters\n nonce = int.from_bytes(urandom(8), \"big\")\n enc_counter = blowfish.ctr_counter(nonce, f = xor)\n dec_counter = blowfish.ctr_counter(nonce, f = xor)\n \n data_encrypted = b\"\".join(cipher.encrypt_ctr(data, enc_counter))\n data_decrypted = b\"\".join(cipher.decrypt_ctr(data_encrypted, dec_counter))\n \n assert data == data_decrypted\n\n.. vim: tabstop=2 expandtab", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/jashandeep-sohi/python-blowfish", "keywords": null, "license": "GPLv3", "maintainer": null, "maintainer_email": null, "name": "blowfish", "package_url": "https://pypi.org/project/blowfish/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/blowfish/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/jashandeep-sohi/python-blowfish" }, "release_url": "https://pypi.org/project/blowfish/0.6.1/", "requires_dist": null, "requires_python": null, "summary": "Fast, efficient Blowfish cipher implementation in pure Python (3.4+).", "version": "0.6.1" }, "last_serial": 1442736, "releases": { "0.4.0": [ { "comment_text": "", "digests": { "md5": "3129ff1c0b50df3d7b2f1f65a7e54e30", "sha256": "47d3ee010b6d4735955c797cc91e84f04af517bce518a8675b086ccc2fb01a19" }, "downloads": -1, "filename": "blowfish-0.4.0.tar.bz2", "has_sig": false, "md5_digest": "3129ff1c0b50df3d7b2f1f65a7e54e30", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 26182, "upload_time": "2014-12-18T09:14:05", "url": "https://files.pythonhosted.org/packages/7a/6f/79a8c5fa61a58b827845db18058016518de010ab69456776606b3690be1d/blowfish-0.4.0.tar.bz2" }, { "comment_text": "", "digests": { "md5": "b116ecc81014e33a5408f387d5b2d729", "sha256": "1b788ea9614b3d0196140f22a3996d04c89addf29a0cec5a84a3db9aec013c2c" }, "downloads": -1, "filename": "blowfish-0.4.0.tar.gz", "has_sig": false, "md5_digest": "b116ecc81014e33a5408f387d5b2d729", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 30567, "upload_time": "2014-12-18T09:14:02", "url": "https://files.pythonhosted.org/packages/45/b2/949c21a2639bc24acd938486c654172173ff66b31f56e69ee5e1cf3c78c8/blowfish-0.4.0.tar.gz" } ], "0.6.0": [ { "comment_text": "", "digests": { "md5": "5e1d25f726d8a6fc4f3dd2df00702c62", "sha256": "1e8b488246c56d0cd5cbc40815d97037841a455a2bb6767e71cd3c5a5e5be2d2" }, "downloads": -1, "filename": "blowfish-0.6.0.tar.bz2", "has_sig": false, "md5_digest": "5e1d25f726d8a6fc4f3dd2df00702c62", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 27870, "upload_time": "2015-01-21T00:38:27", "url": "https://files.pythonhosted.org/packages/0e/05/ececd67645335bdc6d723bb7a9789badb131792de95de15fa4c57b8acdb6/blowfish-0.6.0.tar.bz2" }, { "comment_text": "", "digests": { "md5": "51dc6a56a9c48abdfbe201d040beb564", "sha256": "5a4af1370c9606651420a460822b90601cd1c03f15e35fda6ba551d7dda32fba" }, "downloads": -1, "filename": "blowfish-0.6.0.tar.gz", "has_sig": false, "md5_digest": "51dc6a56a9c48abdfbe201d040beb564", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 32296, "upload_time": "2015-01-21T00:38:25", "url": "https://files.pythonhosted.org/packages/a5/71/1c660b259e03f48271df1f44227626a7863975e5e619f85350c0e84ff4d2/blowfish-0.6.0.tar.gz" } ], "0.6.1": [ { "comment_text": "", "digests": { "md5": "47d9e27f4cd19632400875b19f1ad28f", "sha256": "1626d96d2672a6cf021d9b66a5013b6e594865403b4a06d75034e0a9ff1cbdc6" }, "downloads": -1, "filename": "blowfish-0.6.1.tar.bz2", "has_sig": false, "md5_digest": "47d9e27f4cd19632400875b19f1ad28f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 27824, "upload_time": "2015-02-28T23:38:39", "url": "https://files.pythonhosted.org/packages/ca/06/6008f79f3df714da4eeb6d7daf5e417e072c69923d22ede09171e74d69f8/blowfish-0.6.1.tar.bz2" }, { "comment_text": "", "digests": { "md5": "e4239fcfc9f70062f6f670a7c59d6ea2", "sha256": "a08c6a640ae39afab34dd73f7536a34fa318dfb4c281bc6cb246122210c1e176" }, "downloads": -1, "filename": "blowfish-0.6.1.tar.gz", "has_sig": false, "md5_digest": "e4239fcfc9f70062f6f670a7c59d6ea2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 32298, "upload_time": "2015-02-28T23:38:36", "url": "https://files.pythonhosted.org/packages/a7/a1/17edc0bd3557e7c942e1e145dc253b7262b0d24f10f8744ff57666ff0c19/blowfish-0.6.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "47d9e27f4cd19632400875b19f1ad28f", "sha256": "1626d96d2672a6cf021d9b66a5013b6e594865403b4a06d75034e0a9ff1cbdc6" }, "downloads": -1, "filename": "blowfish-0.6.1.tar.bz2", "has_sig": false, "md5_digest": "47d9e27f4cd19632400875b19f1ad28f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 27824, "upload_time": "2015-02-28T23:38:39", "url": "https://files.pythonhosted.org/packages/ca/06/6008f79f3df714da4eeb6d7daf5e417e072c69923d22ede09171e74d69f8/blowfish-0.6.1.tar.bz2" }, { "comment_text": "", "digests": { "md5": "e4239fcfc9f70062f6f670a7c59d6ea2", "sha256": "a08c6a640ae39afab34dd73f7536a34fa318dfb4c281bc6cb246122210c1e176" }, "downloads": -1, "filename": "blowfish-0.6.1.tar.gz", "has_sig": false, "md5_digest": "e4239fcfc9f70062f6f670a7c59d6ea2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 32298, "upload_time": "2015-02-28T23:38:36", "url": "https://files.pythonhosted.org/packages/a7/a1/17edc0bd3557e7c942e1e145dc253b7262b0d24f10f8744ff57666ff0c19/blowfish-0.6.1.tar.gz" } ] }