Skip to main content

Encrypt symmetric keys with RSA.

Project description

Easy RSA

version license pyversions
donate powered made

Encrypt symmetric keys with RSA.

Hierarchy

easyrsa
'---- EasyRSA()
    |---- gen_private_key()
    |---- gen_public_key()
    |---- encrypt()
    |---- decrypt()
    |---- sign()
    '---- verify()

Example

python

from easyrsa import *

# generate a key pair
kp = EasyRSA(bits=512*2).gen_key_pair()
print(kp)
# {"public_key": b"...", "private_key": b"..."}

# encryption and decryption
# note that each EasyRSA object must bind only one operation
# EasyRSA fails to operate if more than one argument are passed in
from base64 import b64encode
symmetric_key = "abc" or b"abc" or b64encode(b"abc")
encrypted_key = EasyRSA(public_key=kp["public_key"]).encrypt(symmetric_key)
key_in_b64 = b64encode(encrypted_key).decode("utf-8")
print(encrypted_key)
# ...
print(key_in_b64)
# ...
print(symmetric_key == EasyRSA(private_key=kp["private_key"]).decrypt(encrypted_key))
# True
print(symmetric_key == EasyRSA(private_key=kp["private_key"]).decrypt(key_in_b64))
# True

# sign and verify
msg = randb(1024)
s = EasyRSA(private_key=kp["private_key"]).sign(msg)
# and then somehow you receive the msg
print(EasyRSA(public_key=kp["public_key"]).verify(msg, s))
# True

shell

rem easyrsa.exe {private key in base64|public key in base64} {base64 string to decrypt|symmetric key to encrypt}
easyrsa.exe <private key in base64> <base64 string to decrypt>
rem decryption returns string
easyrsa.exe <public key in base64> <symmetric key to encrypt>
rem encryption returns string in b64

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

easyrsa-0.1.3.tar.gz (3.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

easyrsa-0.1.3-py3-none-any.whl (15.8 kB view details)

Uploaded Python 3

File details

Details for the file easyrsa-0.1.3.tar.gz.

File metadata

  • Download URL: easyrsa-0.1.3.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.0

File hashes

Hashes for easyrsa-0.1.3.tar.gz
Algorithm Hash digest
SHA256 6f1c35b9a9b08c817a2dd3d78f7e1fc9734f23f951e080c782c40ae28a922388
MD5 fa315cea5580d1d3fba38565a178ab40
BLAKE2b-256 55287df83a66e0d646dad248ecfce6cefff1bd3f0ce5ef21af7e6a18bbe9898e

See more details on using hashes here.

File details

Details for the file easyrsa-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: easyrsa-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 15.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.0

File hashes

Hashes for easyrsa-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 15f91594c42601bb26bf34b7d6eca2182470ab60b9cc4a16a1056de26c8ee446
MD5 3dbc6d20f4939fb9b3a4887d0fc76eee
BLAKE2b-256 fc5b2af359390e681b61b97e9621b3061889f2edcb686f473c4a449ca3d769b4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page