Clone this repo:
  1. 771a0b0 language correction and speed-up by myheroyuki · 6 weeks ago main
  2. c0d8670 Replace Travis-CI with Github Actions by Sybren A. Stüvel · 6 weeks ago
  3. bc6445a CHANGELOG: include upgrade of mypy by Sybren A. Stüvel · 6 weeks ago
  4. 069f639 rsa/ Clarify functionality of sign_hash() by Moritz Fischer · 6 weeks ago
  5. b94766f modified: Fixed a bug in rsa/ where the message should not be equals to the modulus by Shengkai Sun · 6 weeks ago

Pure Python RSA implementation

PyPI Build Status Coverage Status Code Climate

Python-RSA is a pure-Python RSA implementation. It supports encryption and decryption, signing and verifying signatures, and key generation according to PKCS#1 version 1.5. It can be used as a Python library as well as on the commandline. The code was mostly written by Sybren A. Stüvel.

Documentation can be found at the Python-RSA homepage. For all changes, check the changelog.

Download and install using:

pip install rsa

or download it from the Python Package Index.

The source code is maintained at GitHub and is licensed under the Apache License, version 2.0


Because of how Python internally stores numbers, it is very hard (if not impossible) to make a pure-Python program secure against timing attacks. This library is no exception, so use it with care. See for more info.

Setup of Development Environment

python3 -m venv .venv
. ./.venv/bin/activate
pip install poetry
poetry install

Publishing a New Release

Since this project is considered critical on the Python Package Index, two-factor authentication is required. For uploading packages to PyPi, an API key is required; username+password will not work.

First, generate an API token at Then, use this token when publishing instead of your username and password.

As username, use __token__. As password, use the token itself, including the pypi- prefix.

See for help using API tokens to publish. This is what I have in ~/.pypirc:

index-servers =

# Use `twine upload -r rsa` to upload with this token.
  repository =
  username = __token__
  password = pypi-token
. ./.venv/bin/activate

poetry build
twine check dist/rsa-4.10-dev0.tar.gz dist/rsa-4.10-dev0-*.whl
twine upload -r rsa dist/rsa-4.10-dev0.tar.gz dist/rsa-4.10-dev0-*.whl