{ "info": { "author": "Ben Hodgson", "author_email": "ben@benhodgson.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: Public Domain", "Operating System :: OS Independent", "Programming Language :: Python", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "# Baluhn: Base-agnostic Luhn\n\nBaluhn provides a base-independent implementation of the [Luhn\nalgorithm](http://en.wikipedia.org/wiki/Luhn_algorithm) for Python. It is\nuseful for generating and verifying check digits in arbitrary bases.\n\nFrom Wikipedia:\n\n> The Luhn algorithm or Luhn formula, also known as the \"modulus 10\" or \"mod\n> 10\" algorithm, is a simple checksum formula used to validate a variety of\n> identification numbers, such as credit card numbers, IMEI numbers,\n> National Provider Identifier numbers in US and Canadian Social Insurance\n> Numbers.\n\n## Installation\n\nUse `pip install baluhn` or `python setup.py install`.\n\n## Usage\n\nThe `baluhn` module provides two functions: `verify` and `generate`.\n\n`generate` calculates the Luhn check character for the given input string in\nthe given base. This character should be appended to the input string to\nproduce a valid Luhn string. `verify` tests whether or not a string is a valid\nLuhn string in the given base. By default, Baluhn operates in base 10:\n\n```python\n>>> from baluhn import generate, verify\n>>> verify('5105105105105100') # MasterCard test number\nTrue\n>>> value = '510510510510510' # note the missing check digit\n>>> generate(value)\n'0'\n>>> verify(value + '0')\nTrue\n>>> verify(value + '7')\nFalse\n```\n\nWhen operating in a base other than decimal, encoder and decoder callables\nshould be supplied. The encoder should take a single argument, an integer, and\nreturn the character corresponding to that integer in the operating base.\nConversely, the decoder should take a string containing a single character and\nreturn its integer value in the operating base. Note that the mapping between\nvalues and characters defined by the encoder and decoder should be one-to-one.\n\nFor example, when working in hexadecimal:\n\n```python\n>>> hex_alphabet = '0123456789abcdef'\n>>> hex_encoder = lambda i: hex_alphabet[i]\n>>> hex_decoder = lambda s: hex_alphabet.index(s)\n>>> value = 'a8b56f'\n>>> generate(value, base=16, encoder=hex_encoder, decoder=hex_decoder)\n'b'\n>>> verify('a8b56fb', base=16, decoder=hex_decoder)\nTrue\n>>> verify('a8b56fc', base=16, decoder=hex_decoder)\nFalse\n```\n\n## Author\n\nBaluhn is written by [Ben Hodgson](http://benhodgson.com/) and maintained by [Four Digits](https://fourdigits.nl/).\n\n## (Un)license\n\nThis is free and unencumbered software released into the public domain.\n\nAnyone is free to copy, modify, publish, use, compile, sell, or distribute\nthis software, either in source code form or as a compiled binary, for any\npurpose, commercial or non-commercial, and by any means.\n\nIn jurisdictions that recognize copyright laws, the author or authors of this\nsoftware dedicate any and all copyright interest in the software to the public\ndomain. We make this dedication for the benefit of the public at large and to\nthe detriment of our heirs and successors. We intend this dedication to be an\novert act of relinquishment in perpetuity of all present and future rights to\nthis software under copyright law.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\nACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\nWITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\nFor more information, please refer to ", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/benhodgson/baluhn", "keywords": "luhn,mod10,check digit,luhn mod N", "license": "Public Domain", "maintainer": "Four Digits", "maintainer_email": "info@fourdigits.nl", "name": "baluhn", "package_url": "https://pypi.org/project/baluhn/", "platform": "", "project_url": "https://pypi.org/project/baluhn/", "project_urls": { "Homepage": "http://github.com/benhodgson/baluhn" }, "release_url": "https://pypi.org/project/baluhn/0.1.2/", "requires_dist": null, "requires_python": "", "summary": "A base-agnostic implementation of the Luhn Algorithm for Python. Useful for generating and verifying check digits.", "version": "0.1.2" }, "last_serial": 4939605, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "2a8e5e83f5ed86ced7af755b0daea9fb", "sha256": "d807f945ab8685a90f78aed65e8977da786688024dd800dd3b1e397ac9e4cd49" }, "downloads": -1, "filename": "baluhn-0.1.tar.gz", "has_sig": false, "md5_digest": "2a8e5e83f5ed86ced7af755b0daea9fb", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 1946, "upload_time": "2010-07-19T15:04:39", "url": "https://files.pythonhosted.org/packages/fd/8a/6a11d50bd5be92d7ce3c42c40ffca79cc7d1f7f2e8a803d68a696664487d/baluhn-0.1.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "d36bedb61d80cdb3d34bea2a5a71ae21", "sha256": "c3b5fc9c53ff9dec05f98cac1d3c186d70328ef54e6ce2f76fb2f3f0a3b5e3f2" }, "downloads": -1, "filename": "baluhn-0.1.1.tar.gz", "has_sig": false, "md5_digest": "d36bedb61d80cdb3d34bea2a5a71ae21", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3808, "upload_time": "2019-03-14T12:36:00", "url": "https://files.pythonhosted.org/packages/89/2a/c85ae7a5da323e2dd8d94a7d81911606fab7adcd0b361b40677dfbc11e21/baluhn-0.1.1.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "9b1cc037045b79c350e2b4fd48d6c16f", "sha256": "2d06797789faebf7b68052d101ae5000f6f328e348bd3a2103609834f9bf0b39" }, "downloads": -1, "filename": "baluhn-0.1.2.tar.gz", "has_sig": false, "md5_digest": "9b1cc037045b79c350e2b4fd48d6c16f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3800, "upload_time": "2019-03-14T13:11:24", "url": "https://files.pythonhosted.org/packages/d8/04/1f702c771d387b66f8232afb223db4796372a2e68095078ca76c41d1f151/baluhn-0.1.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "9b1cc037045b79c350e2b4fd48d6c16f", "sha256": "2d06797789faebf7b68052d101ae5000f6f328e348bd3a2103609834f9bf0b39" }, "downloads": -1, "filename": "baluhn-0.1.2.tar.gz", "has_sig": false, "md5_digest": "9b1cc037045b79c350e2b4fd48d6c16f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3800, "upload_time": "2019-03-14T13:11:24", "url": "https://files.pythonhosted.org/packages/d8/04/1f702c771d387b66f8232afb223db4796372a2e68095078ca76c41d1f151/baluhn-0.1.2.tar.gz" } ] }