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.3.0.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.3.0-py3-none-any.whl (15.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: easyrsa-0.3.0.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.3.0.tar.gz
Algorithm Hash digest
SHA256 62a0490efd53049d8e310ff7983c50ebc3f5cbd0ce630427a4202006a234ca0b
MD5 dc9b5cec527c5949d681bf10189867f9
BLAKE2b-256 7991239c0a34065e679fcd04d70e3e6d5a0523f23e6f8747437c448f56b5dba5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: easyrsa-0.3.0-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.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0208558323c3f56f9300787544804ee1f1294ccf01f5ebb44950d120ffa29ace
MD5 4c7e0961b1c4b9131b66e307a7d9af47
BLAKE2b-256 9c800a94996ba575c0d7c987b4497268f1970d597b5371268889866d2b7ce9d8

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