rfc1751


Namerfc1751 JSON
Version 1.0.0 PyPI version JSON
download
home_pagehttps://github.com/remram44/python-rfc1751
SummaryPure Python implementation of the binary-to-text encoding from RFC 1751, S/Key
upload_time2024-04-24 15:34:01
maintainerNone
docs_urlNone
authorRemi Rampin
requires_python<4.0,>=3.8
licenseMIT
keywords binary encoding skey s/key rfc1751 1751
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            This is a Pure-Python implementation of [RFC 1751](https://www.rfc-editor.org/rfc/rfc1751).

Using this small library, you can turn binary strings (for example IDs or passwords) into small sequences of short English words. For example:

```
EB33 F77E E73D 4053
```

would become:

```
TIDE ITCH SLOW REIN RULE MOT
```

The algorithm turns a 64-bit string into 6 English words and vice versa. Two bits of parity are included in the sequence of words, which allow detecting an invalid or corrupted phrase.

# Usage

```pycon
>>> # Simple conversion from string or bytes
>>> rfc1751.bytes_to_string([204, 172, 42, 237, 89, 16, 86, 190])
'RASH BUSH MILK LOOK BAD BRIM'
>>> rfc1751.bytes_to_string(b'\xCC\xAC\x2A\xED\x59\x10\x56\xBE')
'RASH BUSH MILK LOOK BAD BRIM'

>>> # You can specify the separator or get a sequence
>>> rfc1751.bytes_to_string(b'\xCC\xAC\x2A\xED\x59\x10\x56\xBE', sep='-').lower()
'rash-bush-milk-look-bad-brim'
>>> rfc1751.bytes_to_words(b'\xCC\xAC\x2A\xED\x59\x10\x56\xBE')
['RASH', 'BUSH', 'MILK', 'LOOK', 'BAD', 'BRIM']

>>> # Conversion back
>>> rfc1751.string_to_bytes('RASH BUSH MILK LOOK BAD BRIM')
b'\xCC\xAC\x2A\xED\x59\x10\x56\xBE'
>>> list(rfc1751.string_to_bytes('RASH BUSH MILK LOOK BAD BRIM'))
[204, 172, 42, 237, 89, 16, 86, 190]

>>> # You can specify the separator or give a sequence
>>> rfc1751.string_to_bytes('rash-bush-milk-look-bad-brim', sep='-')
b'\xCC\xAC\x2A\xED\x59\x10\x56\xBE'
>>> rfc1751.words_to_bytes(['rash', 'bush', 'milk', 'look', 'bad', 'brim'])
b'\xCC\xAC\x2A\xED\x59\x10\x56\xBE'

>>> # You can also use a custom alphabet as long as it is 2048 words
>>> custom_rfc1751 = rfc1751.Rfc1751(custom_2048_words)
>>> custom_rfc1751.bytes_to_string([204, 172, 42, 237, 89, 16, 86, 190])
'SMILE GENUINE ROBUST RATE AIR GAME'
>>> list(custom_rfc1751.string_to_bytes('SMILE GENUINE ROBUST RATE AIR GAME'))
[204, 172, 42, 237, 89, 16, 86, 190]
```


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/remram44/python-rfc1751",
    "name": "rfc1751",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.8",
    "maintainer_email": null,
    "keywords": "binary, encoding, skey, s/key, rfc1751, 1751",
    "author": "Remi Rampin",
    "author_email": "remi@rampin.org",
    "download_url": "https://files.pythonhosted.org/packages/a8/b3/34f058605134993f6886418120a2ce64f25ff4e35a3f2879872be124f974/rfc1751-1.0.0.tar.gz",
    "platform": null,
    "description": "This is a Pure-Python implementation of [RFC 1751](https://www.rfc-editor.org/rfc/rfc1751).\n\nUsing this small library, you can turn binary strings (for example IDs or passwords) into small sequences of short English words. For example:\n\n```\nEB33 F77E E73D 4053\n```\n\nwould become:\n\n```\nTIDE ITCH SLOW REIN RULE MOT\n```\n\nThe algorithm turns a 64-bit string into 6 English words and vice versa. Two bits of parity are included in the sequence of words, which allow detecting an invalid or corrupted phrase.\n\n# Usage\n\n```pycon\n>>> # Simple conversion from string or bytes\n>>> rfc1751.bytes_to_string([204, 172, 42, 237, 89, 16, 86, 190])\n'RASH BUSH MILK LOOK BAD BRIM'\n>>> rfc1751.bytes_to_string(b'\\xCC\\xAC\\x2A\\xED\\x59\\x10\\x56\\xBE')\n'RASH BUSH MILK LOOK BAD BRIM'\n\n>>> # You can specify the separator or get a sequence\n>>> rfc1751.bytes_to_string(b'\\xCC\\xAC\\x2A\\xED\\x59\\x10\\x56\\xBE', sep='-').lower()\n'rash-bush-milk-look-bad-brim'\n>>> rfc1751.bytes_to_words(b'\\xCC\\xAC\\x2A\\xED\\x59\\x10\\x56\\xBE')\n['RASH', 'BUSH', 'MILK', 'LOOK', 'BAD', 'BRIM']\n\n>>> # Conversion back\n>>> rfc1751.string_to_bytes('RASH BUSH MILK LOOK BAD BRIM')\nb'\\xCC\\xAC\\x2A\\xED\\x59\\x10\\x56\\xBE'\n>>> list(rfc1751.string_to_bytes('RASH BUSH MILK LOOK BAD BRIM'))\n[204, 172, 42, 237, 89, 16, 86, 190]\n\n>>> # You can specify the separator or give a sequence\n>>> rfc1751.string_to_bytes('rash-bush-milk-look-bad-brim', sep='-')\nb'\\xCC\\xAC\\x2A\\xED\\x59\\x10\\x56\\xBE'\n>>> rfc1751.words_to_bytes(['rash', 'bush', 'milk', 'look', 'bad', 'brim'])\nb'\\xCC\\xAC\\x2A\\xED\\x59\\x10\\x56\\xBE'\n\n>>> # You can also use a custom alphabet as long as it is 2048 words\n>>> custom_rfc1751 = rfc1751.Rfc1751(custom_2048_words)\n>>> custom_rfc1751.bytes_to_string([204, 172, 42, 237, 89, 16, 86, 190])\n'SMILE GENUINE ROBUST RATE AIR GAME'\n>>> list(custom_rfc1751.string_to_bytes('SMILE GENUINE ROBUST RATE AIR GAME'))\n[204, 172, 42, 237, 89, 16, 86, 190]\n```\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Pure Python implementation of the binary-to-text encoding from RFC 1751, S/Key",
    "version": "1.0.0",
    "project_urls": {
        "Bug Tracker": "https://github.com/remram44/python-rfc1751/issues",
        "Homepage": "https://github.com/remram44/python-rfc1751",
        "Repository": "https://github.com/remram44/python-rfc1751"
    },
    "split_keywords": [
        "binary",
        " encoding",
        " skey",
        " s/key",
        " rfc1751",
        " 1751"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "00ebed2daece2b2f0dead3f05127a387540fb628d5048c02c4ca70fb6c65fa46",
                "md5": "82429bd1803f87dc3715b955276dad9a",
                "sha256": "3541bb8db86e7b55a8d467572330bcd1a0d3558a0413dccafa23ad4bed22b7a2"
            },
            "downloads": -1,
            "filename": "rfc1751-1.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "82429bd1803f87dc3715b955276dad9a",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.8",
            "size": 8855,
            "upload_time": "2024-04-24T15:34:05",
            "upload_time_iso_8601": "2024-04-24T15:34:05.295337Z",
            "url": "https://files.pythonhosted.org/packages/00/eb/ed2daece2b2f0dead3f05127a387540fb628d5048c02c4ca70fb6c65fa46/rfc1751-1.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a8b334f058605134993f6886418120a2ce64f25ff4e35a3f2879872be124f974",
                "md5": "ed12e731c3db72e339caa55ee4144213",
                "sha256": "448e017ea19fd8f006b3dc88279dd65a62dfea78874f6eb16a7249fabc771ce8"
            },
            "downloads": -1,
            "filename": "rfc1751-1.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "ed12e731c3db72e339caa55ee4144213",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.8",
            "size": 8823,
            "upload_time": "2024-04-24T15:34:01",
            "upload_time_iso_8601": "2024-04-24T15:34:01.767599Z",
            "url": "https://files.pythonhosted.org/packages/a8/b3/34f058605134993f6886418120a2ce64f25ff4e35a3f2879872be124f974/rfc1751-1.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-24 15:34:01",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "remram44",
    "github_project": "python-rfc1751",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "rfc1751"
}
        
Elapsed time: 1.21785s