Converts a $Value to a hash.

@param \eZ\Publish\Core\FieldType\BinaryFile\Value $value

@return mixed
197007
public function toHash(SPIValue $value)
    {
        if ($this->isEmptyValue($value)) {
            return null;
        }

        $hash = parent::toHash($value);

        $hash['downloadCount'] = $value->downloadCount;

        return $hash;
    }
85879
public function toHash(SPIValue $value)
    {
        if ($this->isEmptyValue($value)) {
            return null;
        }

        return $this->hashConverter->convertFromValue($value);
    }
234108
public function decryptSecureCookie($value)
    {
        $cookieValues = explode('|', $value, 4);
        if ((count($cookieValues) === 4) && ($cookieValues[1] == 0 || $cookieValues[1] >= time())) {
            $userid = $cookieValues[0];
            $expire = $cookieValues[1];
            $encrValue = $cookieValues[2];

            $key = hash_hmac('sha1', $userid.$expire, $this->key);
            $value = $this->decrypt(base64_decode(str_replace(' ', '+', $encrValue)), md5($expire));

            if ($this->includeSSLKey == true && ($sslKey = $this->Request->getServerAttribute('SSL_SESSION_ID')))
                $verifyKey = hash_hmac('sha1', $userid . $expire . $value . $sslKey, $key);
            else
                $verifyKey = hash_hmac('sha1', $userid . $expire . $value, $key);

            if (strcmp($verifyKey, $cookieValues[3]) === 0)
                return $value;
        }
        return false;
    }
264487
public static function isHash($value): bool
    {
        if ($value instanceof \stdClass || $value instanceof \ArrayObject) {
            return true;
        }

        $expectedKey = 0;

        foreach ($value as $key => $val) {
            if ($key !== $expectedKey++) {
                return true;
            }
        }

        return false;
    }
134
public function setHash(string $value) : User
    {

        if ($this->data['hash'] !== $value) {
            $this->data['hash'] = $value;
            $this->setModified('hash');
        }

        return $this;
    }
544197
public function fromRaw($value)
    {
        $type = $this->getDataType();

        if ($type === 'json') {
            $value = json_decode($value, true);
        } elseif ($type === 'array') {
            $value = (array) $value;
        } elseif ($type === 'list') {
            $value = explode(',', $value);
        } elseif ($type === 'boolean') {
            $value = $value ? '1' : '0';
        } elseif ($type === 'integer') {
            if (strlen($value)) {
                $value = (int) $value;
            } else {
                $value = null;
            }
        } elseif ($type === 'float') {
            if (strlen($value)) {
                $value = (float) $value;
            } else {
                $value = null;
            }
        }

        return $value;
    }
85074
public static function altEncrypt(
        $value,
        $hash = false,
        $method = self::DEFAULT_CHIPPER
    ) {
        /**
         * Serialize Element
         */
        $string = @serialize([
            $value
        ]);
        if (!$string) {
            throw new \ErrorException(
                sprintf(
                    'Could not serialize input of %s',
                    gettype($string)
                )
            );
        }
        $passKey   = self::createPassKey($hash);
        $crypt_arr = self::cryptStandard(
            $passKey[1],
            $string,
            $method
        );

        $microtime = microtime(true);
        $iv = self::safeBase64Encode($method . $crypt_arr[2]);
        $json_value = json_encode([
            'micro'  => $microtime,
            'method' => $crypt_arr[1],
            'iv'     => $iv,
            'value'  => $crypt_arr[0],
        ]);

        // save as bse64 encode safe
        $crypt_text = trim(
            self::safeBase64Encode(
                $json_value .
                json_encode([
                    sha1($microtime . $passKey[1] . $iv)
                ])
            )
        );

        /**
         * ------------------------------------
         * Inject Result of with sign
         * ------------------------------------
         */
        $pos = abs(round(strlen($passKey[0]) / 3));
        $separator = self::safeBase64Encode(sha1($passKey[1]) . self::STANDARD_MIDDLE);
        if (strlen($crypt_text) > $pos) {
            return substr_replace($crypt_text, $separator . $pos, $pos, 0);
        } else {
            return substr_replace($crypt_text, $separator . $pos, 2, 0);
        }
    }
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;
    }
448965
private function deserialize($value)
    {
        $decoded = base64_decode($value, true);
        if ($decoded === false) {
            return false;
        }

        $decompressed = gzuncompress($decoded);
        return $decompressed;
    }
1275520
protected function castArrayValue($value)
    {
        if (!is_object($value)) {
            return $this->key($value);
        }

        try {
            if ($key = $this->objectCategorizer->key($value)) {
                return $this->hashIfToLong($key);
            }
        } catch (Exception $e) {
        }

        return $this->hashIfToLong($this->objectToKey($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')));
    }
1229507
private function convertBase64ToDec($value)
    {
        $value = unpack('H*', Base64Url::decode($value));

        return $this->convertHexToDec($value[1]);
    }
30698
public function reverseTransform($value)
    {
        if ($value === null || empty($value)) {
            return $this->fieldType->getEmptyValue();
        }

        return $this->fieldType->fromHash(['xml' => $value]);
    }
881945
public function encryptValue($value)
    {
        $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
        $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
        $text = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $this->salt, $value, MCRYPT_MODE_ECB, $iv);

        return trim(base64_encode($text));
    }
1042997
public static function prepareToStore($value)
    {
        // if array - try to prepare every value
        if (is_array($value)) {
            foreach ($value as $k => $v) {
                $value[$k] = self::prepareToStore($v);
            }

            return $value;
        }

        // if scalar - return it
        if (!is_object($value)) {
            return $value;
        }

        // if internal mongo types - pass it as is
        if (TypeChecker::isInternalType($value)) {
            return $value;
        }

        // do not convert geo-json to array
        if ($value instanceof Geometry) {
            return $value->jsonSerialize();
        }

        // structure
        if ($value instanceof Structure) {
            // validate structure
            if (!$value->isValid()) {
                $exception = new InvalidDocumentException('Embedded document not valid');
                $exception->setDocument($value);
                throw $exception;
            }

            // get array from structure
            return $value->toArray();
        }

        // other objects convert to array
        return (array) $value;
    }
1020861
private static function serializeValue( $value ) {
		try {
			return serialize( $value );
		} catch ( \Exception $ex ) {
			self::$logger->error( 'Value serialization failed: ' . $ex->getMessage() );
			return null;
		}
	}
1233865
public function filter($value)
    {
        if ($this->isBinary($value)) {
            return base64_decode(substr($value, BinaryInfo::BINARY_BODY_PREFIX_LENGTH), true);
        }

        return $value;
    }