Encrypt the given value.

@param string $value

@return string
436826
private function encrypt($value)
    {
        $this->checkKey();

        $iv = mcrypt_create_iv(16, MCRYPT_DEV_URANDOM);
        $cipher = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $this->key, json_encode($value), 'ctr', $iv);
        $hmac = hash_hmac('sha256', $iv.$cipher, $this->authentication, true);

        return base64_encode($hmac.$iv.$cipher);
    }
538506
public static function encrypt($value)
        {
            $iv     = mcrypt_create_iv(static::iv_size(), static::randomizer());
            $value  = static::pad($value);
            $value  = mcrypt_encrypt(static::$cipher, static::key(), $value, static::$mode, $iv);
            return base64_encode($iv . $value);
        }
1253292
public function encrypt($value)
    {
        $iv = Str::randomBytes($this->getIvSize());

        $value = \openssl_encrypt(serialize($value), $this->cipher, $this->key, 0, $iv);

        if ($value === false) {
            throw new EncryptException('Could not encrypt the data.');
        }

        $mac = $this->hash($iv = base64_encode($iv), $value);

        return base64_encode(json_encode(compact('iv', 'value', 'mac')));
    }
1162474
public static function maybeEncode($value)
    {
        if (is_array($value) || is_object($value)) {
            $value = json_encode($value);
        }

        return $value;
    }
379072
private static function encodeValue($value)
    {
        $value = gmp_strval($value);

        return Base64Url::encode(self::convertDecToBin($value));
    }
464305
public static function encode($value)
    {
        $encoded = json_encode($value, JSON_UNESCAPED_UNICODE);

        if (JSON_ERROR_NONE !== json_last_error()) {
            throw new \InvalidArgumentException(sprintf(
                'Could not encode value into json. Error %s and message %s',
                json_last_error(),
                json_last_error_msg()
            ));
        }

        return $encoded;
    }
370011
private function encodeQuery(string $value): string
    {
        return preg_replace_callback(
            '/(?:[^'.self::UNRESERVED.self::SUB_DELIMS.':@%~\/\[\]\?]+|%(?![A-Fa-f0-9]{2}))/',
            function (array $match) {
                return rawurlencode($match[0]);
            },
            $value
        );
    }
448965
private function deserialize($value)
    {
        $decoded = base64_decode($value, true);
        if ($decoded === false) {
            return false;
        }

        $decompressed = gzuncompress($decoded);
        return $decompressed;
    }
552219
public function decode($value)
    {


        $prepareForDecrypt = @unserialize(base64_decode(urldecode($value)));
        $preparedIv = base64_decode($prepareForDecrypt['iv']);
        $preparedKey = base64_decode($prepareForDecrypt['key']);

        $value = base64_decode($prepareForDecrypt['value']);

        if (false !== $decypted = @mcrypt_decrypt($this->algorithm, $preparedKey, $value, $this->mode, $preparedIv)) {
            return trim($decypted, "\0\4");
        }

        return false;
    }
1029478
public function decode($value)
    {

        $prepared = unserialize(base64_decode($value));
        $value = base64_decode($prepared['value']);
        $key   = base64_decode($prepared['key']);
        $iv    = base64_decode($prepared['iv']);


        if (false !== $decrypted = openssl_decrypt($value, $this->mode, $key, false, $iv)) {
            return unserialize($decrypted);
        }

        return false;
    }
799961
public static function hash($value)
    {
        $hash = substr(base64_encode(hash('sha256', serialize($value), true)), 0, 7);

        return str_replace(array('/', '+'), array('.', '_'), strtolower($hash));
    }
472228
public function obfuscate($value)
    {
        $safe = '';

        foreach (str_split($value) as $letter) {
            if (ord($letter) > 128) {
                return $letter;
            }

            switch (rand(1, 3)) {
                case 1:
                $safe .= '&#'.ord($letter).';';
                break;
                case 2:
                $safe .= '&#x'.dechex(ord($letter)).';';
                break;
                case 3:
                $safe .= $letter;
            }
        }

        return $safe;
    }
1206284
public function encode($value)
    {
        switch (true) {
            case is_null($value):
                return $this->encodeString('', self::T_NULL);
            case is_bool($value):
                return $this->encodeString($value ? 'true' : 'false', self::T_BOOL);
            case is_int($value):
                return $this->encodeString($value, self::T_INT);
            case is_float($value):
                return $this->encodeString($value, self::T_FLOAT);
            case is_array($value):
                return $this->encodePHPArray($value);

            case is_resource($value):
                throw new InvalidArgumentException("You can't encode a PHP resource as a tagged netstring.");

            default:
                return $this->encodeString($value);
        }
    }
791017
protected function encode($value)
    {
        if (is_array($value)) {
            return array_map([$this, 'encode'], $value);
        } else {
            return str_replace(['+', '%7E'], [' ', '~'], rawurlencode($value));
        }
    }
1133466
public function decrypt($value)
    {
        $decoded = $this->url_decode($value);
        $iv = substr($decoded, 0, 16);
        $encryptedValue = str_replace($iv, '', $decoded);

        return trim(openssl_decrypt($encryptedValue, 'AES-256-CBC', $this->encryptionKey, null, $iv));
    }
1328013
public function encrypt($value)
    {
        $iv = function_exists('random_bytes') ? random_bytes(16) : openssl_random_pseudo_bytes(16);
        $value = openssl_encrypt(serialize($value), $this->_cipher, $this->_key, 0, $iv);

        if ($value === false) {
            throw new AnEncrypterException('Could not encrypt the data.');
        }

        $mac = $this->_hash($iv = base64_encode($iv), $value);
        $json = json_encode(compact('iv', 'value', 'mac'));

        if (! is_string($json)) {
            throw new AnEncrypterException('Could not encrypt the data.');
        }

        return base64_encode($json);
    }
583179
protected function mcryptDecrypt($value, $iv)
	{
		return mcrypt_decrypt($this->cipher, $this->key, $value, $this->mode, $iv);
	}