天天看點

php AES加密解密

public static function encrypt($data, $key) {
    $data = openssl_encrypt($data, 'aes-128-ecb', base64_decode($key), OPENSSL_RAW_DATA);
    return base64_encode($data);
}

public static function decrypt($data, $key) {
    $encrypted = base64_decode($data);
    return openssl_decrypt($encrypted, 'aes-128-ecb', base64_decode($key), OPENSSL_RAW_DATA);
}
           

加解密網站:

http://www.seacha.com/tools/aes.html?src=1&mode=ECB&keylen=128&key=1234567890123456&iv=&bpkcs=pkcs5padding&session=7Q7Rc0QsNO4D4P6UwULu&aes=514f724dba05c8a0e039f062d8637447&encoding=base64&type=1