simple-rsa


Namesimple-rsa JSON
Version 1.1.0 PyPI version JSON
download
home_pagehttps://github.com/christophevg/py-simple-rsa
SummaryA straightforward API to perform basic RSA-based operations..
upload_time2023-07-09 17:59:13
maintainer
docs_urlNone
authorChristophe VG
requires_python
licenseMIT
keywords rsa signing
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI
coveralls test coverage No coveralls.
            # Simple RSA

> A straightforward API to perform basic RSA-based operations.

[![Latest Version on PyPI](https://img.shields.io/pypi/v/simple-rsa.svg)](https://pypi.python.org/pypi/simple-rsa/)
[![Supported Implementations](https://img.shields.io/pypi/pyversions/simple-rsa.svg)](https://pypi.python.org/pypi/simple-rsa/)
[![Coverage Status](https://coveralls.io/repos/github/christophevg/py-simple-rsa/badge.svg?branch=master)](https://coveralls.io/github/christophevg/py-simple-rsa?branch=master)
[![Built with PyPi Template](https://img.shields.io/badge/PyPi_Template-v0.0.6-blue.svg)](https://github.com/christophevg/pypi-template)

## Rationale

Any cryptographic library exposes all possibilities, and it should. But sometimes you just want a simple `sign` and `validate` API. That is what this wrapper module around the Cryptography module is. Nothing more, nothing less.

## Minimal Survival Commands

```console
% pip install simple-rsa
```

When running from the repo (probably in some virtualenv) install cryptography and optionally `tox` is you want to run the tests:

```console
% pip install cryptography tox
```

## Getting Started

The module basically exposes the following functions:

- `generate_key_pair()` returning a tuple of private and public keys
- `encode(key)` returning an encoded key
- `decode(pem)` returning a key
- `sign(payload, key)` returning a signature
- `validate(payload, signature, key)` returning True or an Exception

```bash
$ python
Python 2.7.15 (default, Dec 27 2018, 11:55:59) 
[GCC 4.2.1 Compatible Apple LLVM 10.0.0 (clang-1000.11.45.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import simple_rsa as rsa
>>> private, public = rsa.generate_key_pair()
>>> rsa.encode(public)
'-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA5C15SFjpTCrdqB+0zFyu\nC9KJkNT1byzQPyATtLze/PNWjfqYL0RjvL4cmvmBWLeTQvnDx9SQfnQT02+4Q8Ov\nOaRTPqghEJctAh7KHwZfQzH29miC1WxXtGFcMFoAj17WPyMaOO3EcHqb4ttnAAPD\nt6B415HtGZo4oH6xY7QMj4eRceTv4++zACNHvqArO3bFFiNTBC8vCOpIg3xsYV4w\n7lQZs2lwGlzXPFJUeZglvsWTPJ54E1KabtkC/wSRFZBYtml8ZvzFfNDTOhcDyBR9\nVTV4K7iIGXG0A9C7mmj3hgALS3qSP5EK6fi51ufg98WokCLFcTSD/EphUlixazPo\nOQIDAQAB\n-----END PUBLIC KEY-----\n'
>>> payload = b"something important"
>>> signature = rsa.sign(payload, private)
>>> assert rsa.validate(payload, signature, public)
>>> another_payload = b"something else"
>>> another_signature = rsa.sign(another_payload, private)
>>> assert rsa.validate(payload, another_signature, public)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "simple_rsa/__init__.py", line 74, in validate
    hashes.SHA256()
  File "/usr/local/lib/python2.7/site-packages/cryptography/hazmat/backends/openssl/rsa.py", line 477, in verify
    self._backend, padding, algorithm, self, signature, data
  File "/usr/local/lib/python2.7/site-packages/cryptography/hazmat/backends/openssl/rsa.py", line 272, in _rsa_sig_verify
    raise InvalidSignature
cryptography.exceptions.InvalidSignature
```



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/christophevg/py-simple-rsa",
    "name": "simple-rsa",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "RSA signing",
    "author": "Christophe VG",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/3e/e4/5f2a1e85ab5a465b16e6d921a294349c3aff4159236dfd0422311d65a4f6/simple-rsa-1.1.0.tar.gz",
    "platform": null,
    "description": "# Simple RSA\n\n> A straightforward API to perform basic RSA-based operations.\n\n[![Latest Version on PyPI](https://img.shields.io/pypi/v/simple-rsa.svg)](https://pypi.python.org/pypi/simple-rsa/)\n[![Supported Implementations](https://img.shields.io/pypi/pyversions/simple-rsa.svg)](https://pypi.python.org/pypi/simple-rsa/)\n[![Coverage Status](https://coveralls.io/repos/github/christophevg/py-simple-rsa/badge.svg?branch=master)](https://coveralls.io/github/christophevg/py-simple-rsa?branch=master)\n[![Built with PyPi Template](https://img.shields.io/badge/PyPi_Template-v0.0.6-blue.svg)](https://github.com/christophevg/pypi-template)\n\n## Rationale\n\nAny cryptographic library exposes all possibilities, and it should. But sometimes you just want a simple `sign` and `validate` API. That is what this wrapper module around the Cryptography module is. Nothing more, nothing less.\n\n## Minimal Survival Commands\n\n```console\n% pip install simple-rsa\n```\n\nWhen running from the repo (probably in some virtualenv) install cryptography and optionally `tox` is you want to run the tests:\n\n```console\n% pip install cryptography tox\n```\n\n## Getting Started\n\nThe module basically exposes the following functions:\n\n- `generate_key_pair()` returning a tuple of private and public keys\n- `encode(key)` returning an encoded key\n- `decode(pem)` returning a key\n- `sign(payload, key)` returning a signature\n- `validate(payload, signature, key)` returning True or an Exception\n\n```bash\n$ python\nPython 2.7.15 (default, Dec 27 2018, 11:55:59) \n[GCC 4.2.1 Compatible Apple LLVM 10.0.0 (clang-1000.11.45.5)] on darwin\nType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\n>>> import simple_rsa as rsa\n>>> private, public = rsa.generate_key_pair()\n>>> rsa.encode(public)\n'-----BEGIN PUBLIC KEY-----\\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA5C15SFjpTCrdqB+0zFyu\\nC9KJkNT1byzQPyATtLze/PNWjfqYL0RjvL4cmvmBWLeTQvnDx9SQfnQT02+4Q8Ov\\nOaRTPqghEJctAh7KHwZfQzH29miC1WxXtGFcMFoAj17WPyMaOO3EcHqb4ttnAAPD\\nt6B415HtGZo4oH6xY7QMj4eRceTv4++zACNHvqArO3bFFiNTBC8vCOpIg3xsYV4w\\n7lQZs2lwGlzXPFJUeZglvsWTPJ54E1KabtkC/wSRFZBYtml8ZvzFfNDTOhcDyBR9\\nVTV4K7iIGXG0A9C7mmj3hgALS3qSP5EK6fi51ufg98WokCLFcTSD/EphUlixazPo\\nOQIDAQAB\\n-----END PUBLIC KEY-----\\n'\n>>> payload = b\"something important\"\n>>> signature = rsa.sign(payload, private)\n>>> assert rsa.validate(payload, signature, public)\n>>> another_payload = b\"something else\"\n>>> another_signature = rsa.sign(another_payload, private)\n>>> assert rsa.validate(payload, another_signature, public)\nTraceback (most recent call last):\n  File \"<stdin>\", line 1, in <module>\n  File \"simple_rsa/__init__.py\", line 74, in validate\n    hashes.SHA256()\n  File \"/usr/local/lib/python2.7/site-packages/cryptography/hazmat/backends/openssl/rsa.py\", line 477, in verify\n    self._backend, padding, algorithm, self, signature, data\n  File \"/usr/local/lib/python2.7/site-packages/cryptography/hazmat/backends/openssl/rsa.py\", line 272, in _rsa_sig_verify\n    raise InvalidSignature\ncryptography.exceptions.InvalidSignature\n```\n\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A straightforward API to perform basic RSA-based operations..",
    "version": "1.1.0",
    "project_urls": {
        "Homepage": "https://github.com/christophevg/py-simple-rsa"
    },
    "split_keywords": [
        "rsa",
        "signing"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "69a62d4d734768495db74575720f5cf73c2ea5082abf4ea66dec9a0f1660a3a6",
                "md5": "d9861a40884e88f3998f7bb775b32fe4",
                "sha256": "265bc76e395ead6460edff9adc0fa512c27030655a562da4ee78039bd30dbff4"
            },
            "downloads": -1,
            "filename": "simple_rsa-1.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "d9861a40884e88f3998f7bb775b32fe4",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 4465,
            "upload_time": "2023-07-09T17:59:12",
            "upload_time_iso_8601": "2023-07-09T17:59:12.368272Z",
            "url": "https://files.pythonhosted.org/packages/69/a6/2d4d734768495db74575720f5cf73c2ea5082abf4ea66dec9a0f1660a3a6/simple_rsa-1.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3ee45f2a1e85ab5a465b16e6d921a294349c3aff4159236dfd0422311d65a4f6",
                "md5": "a052ad9d0d04245017a3423b6dd95518",
                "sha256": "7a9d68532cca651f8f58ee8cff8222a6dc48773c2b9e695c3d3996604cc8f978"
            },
            "downloads": -1,
            "filename": "simple-rsa-1.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "a052ad9d0d04245017a3423b6dd95518",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 5246,
            "upload_time": "2023-07-09T17:59:13",
            "upload_time_iso_8601": "2023-07-09T17:59:13.880237Z",
            "url": "https://files.pythonhosted.org/packages/3e/e4/5f2a1e85ab5a465b16e6d921a294349c3aff4159236dfd0422311d65a4f6/simple-rsa-1.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-07-09 17:59:13",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "christophevg",
    "github_project": "py-simple-rsa",
    "travis_ci": true,
    "coveralls": false,
    "github_actions": false,
    "tox": true,
    "lcname": "simple-rsa"
}
        
Elapsed time: 0.09296s