3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(strict_types=1); class SensitiveInfo { private $cipher = "AES-256-CBC"; private $secret_key = "fj239fDSDf932kk21c"; private $secret_iv = "3fn4d2k3j3nxdlpo32"; private $options = 0; private $iv = null; public function __construct() { $this->secret_key = hash('sha256', $this->secret_key); $this->iv = substr(hash('sha256', $this->secret_iv), 0, 16); }//end __construct() public function hide(string $str): string { return base64_encode(openssl_encrypt( $str, $this->cipher, $this->secret_key, $this->options, $this->iv )); }//end maskData() public function unhide(string $str) { $str = base64_decode($str); return openssl_decrypt( $str, $this->cipher, $this->secret_key, $this->options, $this->iv ); }//end maskData() }//end class $si = new SensitiveInfo(); $encrypted = $si->hide("Hello World"); var_dump($encrypted); var_dump($si->unhide($encrypted));

preferences:
60.09 ms | 402 KiB | 5 Q