Skip to content

Instantly share code, notes, and snippets.

View Spationaute's full-sized avatar
🏠
Working from home

Gabriel St-Pierre-Lemieux Spationaute

🏠
Working from home
View GitHub Profile
@syedrakib
syedrakib / RSA_example.py
Last active August 3, 2023 18:22
An example of asymmetric encryption in python using a public/private keypair - utilizes RSA from PyCrypto library
# 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 # use larger value in production