Skip to content

Instantly share code, notes, and snippets.

View GavinAren's full-sized avatar
💭

Gavin Aren GavinAren

💭
View GitHub Profile
@syedrakib
syedrakib / RSA_example.py
Last active June 21, 2024 19:48
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