
Product
Introducing Socket Fix for Safe, Automated Dependency Upgrades
Automatically fix and test dependency updates with socket fix—a new CLI tool that turns CVE alerts into safe, automated upgrades.
Overview
This script demonstrates cryptographic operations like AES encryption/decryption, RSA encryption/decryption, and hashing using Python's pycryptodome, base64, and hashlib library.
Features
AES Encryption (ECB): Encrypts and decrypts data using AES in ECB mode.
RSA Key Pair Generation: Creates 2048-bit RSA keys.
RSA Encryption/Decryption: Uses PKCS1_OAEP padding for secure RSA operations.
Hashing: Supports MD5, SHA-1, SHA-224, SHA-256, SHA-384, and SHA-512.
Dependencies
pip install -r requirements.txt
Function Details
AES Encryption/Decryption
aes_encrypt_ecb(data, key)
Encrypts plaintext using AES in ECB mode.
Args:
data (str): The plaintext to encrypt.
key (bytes): A key of length 16, 24, or 32 bytes.
Returns:
Encrypted data (bytes).Function Details
aes_decrypt_ecb(ciphertext, key)
Decrypts AES-encrypted ciphertext in ECB mode.
Args:
ciphertext (bytes): The encrypted data.
key (bytes):
The decryption key.
Returns:
Decrypted plaintext (str).
RSA Encryption/Decryption
generate_rsa_keys()
Generates a pair of RSA public and private keys.
Returns:
private_key (bytes): RSA private key.
public_key (bytes): RSA public key.
rsa_encrypt(plaintext, public_key)
Encrypts plaintext using an RSA public key.
Args:
plaintext (str): The plaintext to encrypt.
public_key (bytes): The RSA public key.
Returns:
Encrypted data (bytes).
rsa_decrypt(encrypted_data, private_key)
Decrypts RSA-encrypted data using a private key.
Args:
encrypted_data (bytes): The encrypted data.
private_key (bytes): The RSA private key.
Returns:
Decrypted plaintext (str).
All hashing functions:
md5_hash(data): Generates an MD5 hash of the input data.
sha1_hash(data): Generates a SHA-1 hash.
sha224_hash(data): Generates a SHA-224 hash.
sha256_hash(data): Generates a SHA-256 hash.
sha384_hash(data): Generates a SHA-384 hash.
sha512_hash(data): Generates a SHA-512 hash.
Args: data (str): Input string to hash.
Returns: Hash value (str).
Outputs
RSA: Encrypts and decrypts plaintext securely.
AES: Encrypts and decrypts text using AES with a random key.
Hashing: Generates cryptographic hashes for text.
Security Notes
ECB mode leaks patterns; use safer modes like CBC or GCM for production.
This script is for educational purposes only.
License
This project is licensed under the Apache2 reset License
FAQs
A simple AES and RSA encryption package
We found that encryptions demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Automatically fix and test dependency updates with socket fix—a new CLI tool that turns CVE alerts into safe, automated upgrades.
Security News
CISA denies CVE funding issues amid backlash over a new CVE foundation formed by board members, raising concerns about transparency and program governance.
Product
We’re excited to announce a powerful new capability in Socket: historical data and enhanced analytics.