High encryption / decryption performance in both PHP and MySQL

I like the redesign of some aspects of my database / website, and I am looking for reasonably strong crypto functions in PHP that are also supported by MySQL.

I also need encryption / decryption to be 100% portable and compatible.

Basically, I will encrypt in PHP, selecting the encrypted version from MySQL, and then decrypting in PHP. But sometimes I need to run a query that decrypts a field in MySQL, for reporting purposes, etc.

I looked at mycrypt php library, but it is unclear which of these ciphers is supported by MySQL. Any recommendations?

+5
source share
3 answers

Google-fu, , MySQL 128- AES Electronic Codebook (ECB). , 16 .

, _My-16-byte-key_ .

SELECT AES_ENCRYPT('The rooster crows at midnight!', '_My-16-byte-key_')

: 7e41520667dc20457db2f18644bad06dd62a2120be8b93cd5596d8ffea45ef0f

PHP mcrypt_decrypt, :

$secret = '7e41520667dc20457db2f18644bad06dd62a2120be8b93cd5596d8ffea45ef0f';
$key = '_My-16-byte-key_';
print mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $key, pack('H*', $secret), 'ecb');

:

!

. =)

+3

: http://dev.mysql.com/doc/refman/5.5/en/encryption-functions.html
MySQL.

AES.
.
AES 128- ( 256 MYSQL).
, AES, . a >

, , , , - ( ) , .

-: SHA256 .

+1

I also recommend AES, it is designed to be fast, and since it is an industry standard, it is robust enough. However, what is the reason for encrypting data inside the database? If your encryption key is stored in PHP scripts, it will not be more secure than using cleartext entries. It has advantages only if many scripts access the same database.

0
source

All Articles