Skip to content

Instantly share code, notes, and snippets.

View mynamezxc's full-sized avatar
🍒
O.O

Nguyên Hoàng mynamezxc

🍒
O.O
  • TS24
View GitHub Profile
@mynamezxc
mynamezxc / encryption.php
Created January 19, 2021 09:21 — forked from eoli3n/encryption.php
Encrypt - Decrypt AES from - to Python PyCrypto 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;
@mynamezxc
mynamezxc / openssl_encrypt_decrypt.php
Created January 18, 2021 04:23 — forked from joashp/openssl_encrypt_decrypt.php
Simple PHP encrypt and decrypt using OpenSSL
<?php
/**
* simple method to encrypt or decrypt a plain text string
* initialization vector(IV) has to be the same when encrypting and decrypting
*
* @param string $action: can be 'encrypt' or 'decrypt'
* @param string $string: string to encrypt or decrypt
*
* @return string
*/

Keybase proof

I hereby claim:

  • I am mynamezxc on github.

  • I am mynamezxc (https://keybase.io/mynamezxc) on keybase.

  • I have a public key ASCkPdg38pEBab-UafS0mTezinnjp1MdmdMqmymhd6pP9go