Hi! Could we please enable some services and cookies to improve your experience and our website?

PHPize Online / SQLize Online  /  SQLtest Online

A A A
Login    Share code      Blog   FAQ

Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code

Copy Format Clear

Stuck with a problem? Got Error? Ask AI support!

Copy Clear
Copy Format Clear
<?php define('RYQ_AES_KEY_B64', 'gSfzdcv50NR45AoFrBeQMv3jglVWCRCP3SwcBYO4V64='); define('RYQ_AES_IV_CBC_B64', '8XATuCHa47fUUvulcaF8wg=='); function encrypt_rut($rut) { $key = base64_decode(RYQ_AES_KEY_B64); $iv_cbc = base64_decode(RYQ_AES_IV_CBC_B64); // 16 bytes EXÁCTOS // RUT con guión, sin puntos, mayúsculas $rut = strtoupper(trim($rut)); $rut = str_replace('.', '', $rut); if (strpos($rut, '-') === false && strlen($rut) > 1) { $rut = substr($rut, 0, -1) . '-' . substr($rut, -1); } $encrypted = openssl_encrypt($rut, 'AES-256-CBC', $key, OPENSSL_RAW_DATA, $iv_cbc); $b64 = base64_encode($encrypted); echo "RUT encriptado: $b64\n"; } encrypt_rut('16042486-9'); // Debería dar ZY+7QfJSqAuAJdn2VrpUqQ==
Copy Clear