public function encrypt(string $value, string $key = null): string
    {
        if ($key === null) {
            $key = $this->getDefaultKey();
        }
        $iv = openssl_random_pseudo_bytes(openssl_cipher_iv_length($this->cipher));
        return $iv . openssl_encrypt($value, $this->cipher, $key, 0, $iv);
    }
public function encrypt(string $value, string $key = null): string
    {
        if ($key === null) {
            $key = $this->getDefaultKey();
        }
        $iv = openssl_random_pseudo_bytes(openssl_cipher_iv_length($this->cipher));
        return $iv . openssl_encrypt($value, $this->cipher, $key, 0, $iv);
    }
public function encrypt ( string $ value , string $ key = null ) : string { if ( $ key === null ) { $ key = $ this -> getDefaultKey ( ) ; } $ iv = openssl_random_pseudo_bytes ( openssl_cipher_iv_length ( $ this -> cipher ) ) ; return $ iv . openssl_encrypt ( $ value , $ this -> cipher , $ key , 0 , $ iv ) ; }
Encrypts the value provided. The default key will be used if none specified.

@param string $value
@param string $key
@return string
Encrypts the value provided . The default key will be used if none specified .