Skip to content

Instantly share code, notes, and snippets.

@thomascys
Created February 27, 2020 19:31
Show Gist options
  • Save thomascys/c11b70a3b24af4bd46b87372d7bf6a56 to your computer and use it in GitHub Desktop.
Save thomascys/c11b70a3b24af4bd46b87372d7bf6a56 to your computer and use it in GitHub Desktop.
<?php
// Encrypt data with PHP openssl_encrypt AES-128-CBC.
$data = 'The quick brown fox jumps over the lazy dog.';
$key = '2b7e151628aed2a6abf7158809cf4f3c';
$iv = '000102030405060708090a0b0c0d0e0f';
$encrypted_data = bin2hex(openssl_encrypt($data, 'AES-128-CBC', hex2bin($key), OPENSSL_RAW_DATA, hex2bin($iv)));
// Should output bd13204f67d8167f20211c99b0a7cc0506d5c703eafb01a7d0473b5cc999aaa21e017b766e52985f5ef7f0bdc572b72e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment