Skip to content

Instantly share code, notes, and snippets.

View bertrand-caron's full-sized avatar

Dr. Bertrand Caron, PhD bertrand-caron

View GitHub Profile
@bertrand-caron
bertrand-caron / RSA_example.py
Last active June 6, 2018 03:17 — forked from syedrakib/RSA_example.py
An example of asymmetric encryption in python using a public/private keypair - utilizes RSA from PyCrypto library and Python3.5
# Inspired from http://coding4streetcred.com/blog/post/Asymmetric-Encryption-Revisited-(in-PyCrypto)
# PyCrypto docs available at https://www.dlitz.net/software/pycrypto/api/2.6/
from Crypto import Random
from Crypto.PublicKey import RSA
import base64
def generate_keys():
# RSA modulus length must be a multiple of 256 and >= 1024
modulus_length = 256 * 4 * 4 # use larger value in production