Skip to content

Instantly share code, notes, and snippets.

View MooneDrJune's full-sized avatar
:octocat:
Enchanting Technology

DrJuneMoone MooneDrJune

:octocat:
Enchanting Technology
View GitHub Profile
@frizz925
frizz925 / main.py
Last active May 28, 2024 02:47
AES-256-CBC w/ Base64 using PyCryptodome library
from Crypto.Cipher import AES
from Crypto.Util import Padding
from hashlib import md5
from base64 import b64encode, b64decode
import sys
passphrase = sys.argv[1]
content = sys.argv[2]
print(passphrase, content)
@eoli3n
eoli3n / encryption.php
Last active May 30, 2025 19:02
Encrypt - Decrypt AES from/to Python PyCryptodome from/to PHP openssl
<?php
// use to generate key : 'openssl rand -hex 32'
function my_encrypt($data, $passphrase) {
$secret_key = hex2bin($passphrase);
$iv = openssl_random_pseudo_bytes(openssl_cipher_iv_length('aes-256-cbc'));
$encrypted_64 = openssl_encrypt($data, 'aes-256-cbc', $secret_key, 0, $iv);
$iv_64 = base64_encode($iv);
$json = new stdClass();
$json->iv = $iv_64;