File manager - Edit - /home/autoph/public_html/projects/golf/app/Utilities/Encrypt.php
Back
<?php namespace App\Utilities; class Encrypt { public static function safe_b64encode($string = '') { $data = base64_encode($string); $data = str_replace(['+', '/', '='], ['-', '_', ''], $data); return $data; } public static function safe_b64decode($string = '') { $data = str_replace(['-', '_'], ['+', '/'], $string); $mod4 = strlen($data) % 4; if ($mod4) { $data .= substr('====', $mod4); } return base64_decode($data); } public static function encode($value = false) { if (!$value) return false; $iv_size = openssl_cipher_iv_length('aes-256-cbc'); $iv = openssl_random_pseudo_bytes($iv_size); $crypttext = openssl_encrypt($value, 'aes-256-cbc', env('APP_KEY'), OPENSSL_RAW_DATA, $iv); return self::safe_b64encode($iv . $crypttext); } public static function decode($value = false) { if (!$value) return false; $crypttext = self::safe_b64decode($value); $iv_size = openssl_cipher_iv_length('aes-256-cbc'); $iv = substr($crypttext, 0, $iv_size); $crypttext = substr($crypttext, $iv_size); if (!$crypttext) return false; $decrypttext = openssl_decrypt($crypttext, 'aes-256-cbc', env('APP_KEY'), OPENSSL_RAW_DATA, $iv); return rtrim($decrypttext); } }
| ver. 1.4 |
.
| PHP 8.1.32 | Generation time: 0.09 |
proxy
|
phpinfo
|
Settings