mysqlAES package supports AES 128/192/256 encryptioin, and this API is compatible with lib_mysqludf_aes256 MySQL UDF and mysqlAES javascript API.
Also, this api supports hex and unhex API that is compatble with MySQL and MariaDB.
If encrypt with 128bit, this api is operate in the same way with AES_ENCRYPT and AES_DECRYPT of MySQL or MariaDB.
BSD 2-Clause
mysqlAES 2.x works with PHP 7.1 and later. Use mysqlAES-1 branch or 1.x version for use with PHP 7.0 and before. The mysqlAES-1 branch also supports php 7 and later.
mysqlAES package needs follow external libraries.
- php openssl extension
And, you can install in three ways that are download source files by hands or using pear command or use composer. If you choose to install manually, you will also need to install the required external libraries yourself. Therefore, it is recommended to use the pear command to reduce this effort.
- download latest version at release page.
- uncompress the downloaded package to the desired path.
- add the path in the include_path ini option.
- include mysqlAES.php file in your code.
This method is needed root privileges.
[root@host ~]$ pear channel-discover pear.oops.org
[root@host ~]$ pear install oops/mysqlAES
[root@host ~]$ pear list -a
first, make composer.json as follow:
{
"require": {
"joungkyun/mysqlaes": "2.*"
}
}
and, install mysqlAES
[user@host project]$ php composer.phpt install
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 1 installs, 0 updates, 0 removals
- Installing joungkyun/mysqlaes (2.0.0): Downloading (100%)
Writing lock file
Generating autoload files
[user@host project]$
and, write code as follow:
<?php
require_once 'vendor/autoload.php';
echo 'mysqlAES is supported ';
if ( class_exists ('oops\Encrypt\mysqlAES') )
echo 'YES';
else
echo 'NO';
echo "\n";
?>
See also mysqlAES reference pages. If you want to mysqlAES-1 reference, see also mysqlAES-1 reference pages.
- (string|null) oops\Encrypt\mysqlAES::hex(STRING)
- (string|null) oops\Encrypt\mysqlAES::unhex(STRING)
- (string|null) oops\Encrypt\mysqlAES::encrypt(STRING, KEY)
- (string|null) oops\Encrypt\mysqlAES::decrypt(ENCRYPTED_STRING, KEY)
<?php
require_once 'mysqlAES.php';
use oops\Encrypt;
$string = "123 abced\n";
$key = '0123456789012345';
$enc = mysqlAES::hex (mysqlAES::encrypt ($string, $key));
$dec = mysqlAES::decrypt (mysqlAES::unhex ($enc), $key);
?>
This class is compatible with follow APIs:
- MySQL UDF lib_mysqludf_aes256
- javascript mysqlAES class