{ "info": { "author": "Eric Wong", "author_email": "ericwong@zju.edu.cn", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Topic :: Security", "Topic :: Security :: Cryptography", "Topic :: Software Development", "Topic :: Software Development :: Libraries", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "![version](https://img.shields.io/pypi/v/des.svg) ![license](https://img.shields.io/pypi/l/des.svg)\n\n# DES (Data Encryption Standard)\nA pure Python implementation for the famous DES algorithm, supporting Python 2 and 3.\n\n## Installation\nUsing `pip`:\n```bash\n$ pip install des \n```\n\nOr manually download the archive and run the command after extracting the stuff inside:\n```bash\n$ python setup.py install\n```\n\n## Usage\nFirstly, define a `DesKey` object by passing your encryption / decryption key. The key should be of length 8, 16 or 24. The algorithm will be automatically chosen for you.\nNote that the key should be written as `bytes` in *Python 3*.\n```python\nfrom des import DesKey\nkey0 = DesKey(b\"some key\") # for DES\nkey1 = DesKey(b\"a key for TRIPLE\") # for 3DES, same as \"a key for TRIPLEa key fo\"\nkey2 = DesKey(b\"a 24-byte key for TRIPLE\") # for 3DES\nkey3 = DesKey(b\"1234567812345678REAL_KEY\") # for DES, same as \"REAL_KEY\"\n```\n\nYou may know whether a key is for *DES* or *3DES* algorithm by calling its method `is_single()` or `is_triple()`.\n```python\nkey0.is_single() # -> True\nkey1.is_triple() # -> True\nkey2.is_single() # -> False\nkey3.is_triple() # -> False\n```\n\nSecondly, encrypt messages by calling the method `encrypt()` from the `DesKey` object, or decrypt them by calling `decrypt()`.\nNote that the messages should be written as `bytes` in *Python 3*.\n```python\nkey0.encrypt(b\"any long message\") # -> b\"\\x14\\xfa\\xc2 '\\x00{\\xa9\\xdc;\\x9dq\\xcbr\\x87Q\"\n```\n\nBy default, *ECB Mode* is used. You may enable *CBC Mode* by passing the argument `initial`, as the *Initial Value*.\nThe argument may be either a `bytes` object of length 8 or an integer using *big-endian*. \n```python\nkey0.encrypt(b\"any long message\", initial=0) # -> b\"\\x14\\xfa\\xc2 '\\x00{\\xa9\\xb2\\xa5\\xa7\\xfb#\\x86\\xc5\\x9b\"\nkey0.encrypt(b\"any long message\", initial=b\"\\0\"*8) # same as above\n```\n\nThe *DES* algorithm requires the message to be of any length that is a multiple of 8.\nBy default, the length of the message to encrypt / decrypt is assured by users.\nYou may choose to turn on *PKCS5 Padding Mode*(by passing the argument `padding` with a TRUTHY value), telling Python to do the padding before encryption for you.\n```python\nkey0.encrypt(b\"abc\", padding=True) # -> b\"%\\xd1KU\\x8b_A\\xa6\"\n```\n\nWhile in decryption with *PKCS5 Padding*, the length of the message is still required to be a multiple of 8. But after decryption, Python will throw the padding characters away. \n```python\nkey0.decrypt(b\"%\\xd1KU\\x8b_A\\xa6\", padding=True) # -> b\"abc\"\n```", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/littlefisher/des", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "des", "package_url": "https://pypi.org/project/des/", "platform": "", "project_url": "https://pypi.org/project/des/", "project_urls": { "Homepage": "https://github.com/littlefisher/des" }, "release_url": "https://pypi.org/project/des/1.0.5/", "requires_dist": null, "requires_python": "", "summary": "A pure Python implementation for the famous DES algorithm", "version": "1.0.5" }, "last_serial": 5195981, "releases": { "1.0.4": [ { "comment_text": "", "digests": { "md5": "be989f9b5b1815cddea50987d9d52d2c", "sha256": "62e1412fa1f1444f2f960635a1f9f7775b59ebfcb2930203028cc6ced2a9c97c" }, "downloads": -1, "filename": "des-1.0.4.tar.gz", "has_sig": false, "md5_digest": "be989f9b5b1815cddea50987d9d52d2c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5700, "upload_time": "2019-01-01T06:03:33", "url": "https://files.pythonhosted.org/packages/46/ec/eb71caf239a25e97e5a713c3ca9a0984e16f6fb79d428bc5f42d1884bb19/des-1.0.4.tar.gz" } ], "1.0.5": [ { "comment_text": "", "digests": { "md5": "856c9f52b11b522af5f6ea8202b56cde", "sha256": "4f7fb585bf04cd79fd435822dbd03e25872117e78f1e862c8501beeb48af4818" }, "downloads": -1, "filename": "des-1.0.5.tar.gz", "has_sig": false, "md5_digest": "856c9f52b11b522af5f6ea8202b56cde", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5699, "upload_time": "2019-04-27T06:36:22", "url": "https://files.pythonhosted.org/packages/87/d2/43554da481f4c2fcd4291f3a2d99a45ea342fd2949dd15920f3c232e4880/des-1.0.5.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "856c9f52b11b522af5f6ea8202b56cde", "sha256": "4f7fb585bf04cd79fd435822dbd03e25872117e78f1e862c8501beeb48af4818" }, "downloads": -1, "filename": "des-1.0.5.tar.gz", "has_sig": false, "md5_digest": "856c9f52b11b522af5f6ea8202b56cde", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5699, "upload_time": "2019-04-27T06:36:22", "url": "https://files.pythonhosted.org/packages/87/d2/43554da481f4c2fcd4291f3a2d99a45ea342fd2949dd15920f3c232e4880/des-1.0.5.tar.gz" } ] }