Decode and decrypt group values.

@param string $value
@return array
350323
public function decode($value)
    {
        $json = parent::decode($value);

        $values = json_decode($json, true);

        $this->handleJsonError('Failed to decode group values from JSON');

        return $values;
    }
720295
public function decode($value)
    {
        if (is_array($value)) {
            $newValue = array();
            foreach ($value as $key => $val) {
                $newValue[$key] = html_entity_decode($val, ENT_QUOTES, 'UTF-8');
            }

            return $newValue;
        }

        return html_entity_decode($value, ENT_QUOTES, 'UTF-8');
    }
1067081
private function decodeValue($value) {

        $children = $value->children();

        if ( count($children) != 1 ) throw new XmlrpcException("Cannot decode value: invalid value element");

        $child = $children[0];

        $child_type = $child->getName();

        switch ( $child_type ) {

            case "i4":
            case "int":
                $return_value = $this->decodeInt($child);
            break;

            case "double":
                $return_value = $this->decodeDouble($child);
            break;

            case "boolean":
                $return_value = $this->decodeBool($child);
            break;

            case "base64":
                $return_value = $this->decodeBase($child);
            break;
            
            case "dateTime.iso8601":
                $return_value = $this->decodeIso8601Datetime($child);
            break;

            case "string":
                $return_value = $this->decodeString($child);
            break;

            case "array":
                $return_value = $this->decodeArray($child);
            break;
            
            case "struct":
                $return_value = $this->decodeStruct($child);
            break;
            
            case "nil":
            case "ex:nil":
                $return_value = $this->decodeNil();
            break;
            
            default:
                throw new XmlrpcException("Cannot decode value: invalid value type");
            break;

        }

        return $return_value;

    }
1145782
private function prepareValue($value)
    {
        if (is_array($value)) {
            foreach ($value as &$val) {
                if (is_array($val) and count($val) === 1) {
                    $val = array_shift($val);
                }
            }
            unset($val);

            if (count($value) === 1) {
                $value = array_shift($value);
            }
        }

        return $value;
    }
210642
protected function decodeArrayValue($value, $delimeter = '|')
    {
        if (strpos($value, $delimeter) === false) return [$value];

        $data = preg_split('~(?<!\\\)' . preg_quote($delimeter, '~') . '~', $value);
        $newData = [];

        foreach ($data as $_value) {
            $newData[] = str_replace('\\'.$delimeter, $delimeter, $_value);
        }

        return $newData;
    }
224289
protected function stringDecode($value)
    {
        // Handle empty case
        if (empty($value)) {
            return array();
        }

        // If json deserialisation fails, then fallover to legacy format
        $result = json_decode($value, true);
        if ($result !== false) {
            return $result;
        }

        throw new \InvalidArgumentException("Invalid string encoded value for multi select field");
    }
921681
public static function jsonDecode($value)
    {
        if (defined('JSON_PARSER_NOTSTRICT')) { // pecl-json-c ext
            $decoded = json_decode($value, false, 512, JSON_PARSER_NOTSTRICT);
        } else { // json-ext
            $decoded = json_decode($value);
        }

        return $decoded;
    }
153109
public function encode($value)
    {

        $createdIv = $this->createIvSizeAndIvString();
        $createdKey = $this->createSpecialKey($createdIv);

        if (false !== $encrypted = @mcrypt_encrypt($this->algorithm, $createdKey, $value, $this->mode, $createdIv)) {

            return urlencode(base64_encode(
                serialize(
                    [
                        'iv'    => base64_encode($createdIv),
                        'key'   => base64_encode($createdKey),
                        'value' => trim(base64_encode($encrypted)),
                    ]
                )
            ));
        }

        return false;
    }
1091236
function unicode_decode($value)
    {
        
        $pattern = '/(?:\\\u(?:[\w]{4}))|(?:\\\x(?:[\w]{2}))|./i';
        preg_match_all($pattern, $value, $matches);
        if (!empty($matches))
        {
            $value = '';
            for ($j = 0; $j < count($matches[0]); $j++)
            {
                $unistr = $matches[0][$j];
                if (strpos($unistr, '\\u') === 0)
                {
                    $code = base_convert(substr($unistr, 2, 2), 16, 10);
                    $code2 = base_convert(substr($unistr, 4), 16, 10);
                    $c = chr($code).chr($code2);
                    $c = iconv('UCS-2', 'UTF-8', $c);
                    $value .= $c;
                }
                elseif (strpos($unistr, '\\x') === 0)
                {
                    $code = base_convert(substr($unistr, 2, 1), 16, 10);
                    $code2 = base_convert(substr($unistr, 3), 16, 10);
                    if ($code > 7) {
                        $c = chr($code).chr($code2);
                        $c = iconv('UCS-2', 'UTF-8', $c);
                    } else {
                        $c = chr(hexdec(substr($unistr, 2, 2)));
                    }
                    $value .= $c;
                    /**/
                    
                    /*
                     $code = hexdec(substr($value, 2, 2));
                     $c = chr($code);
                     $name .= $c;
                     */
                }
                else
                {
                    $value .= $unistr;
                }
            }
        }
        return $value;
    }
217888
public function decryptValue($value)
    {
        $decoded = base64_decode($value);
        $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
        $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
        $text = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $this->salt, $decoded, MCRYPT_MODE_ECB, $iv);

        return trim($text);
    }
1090800
public function encrypt($value)
    {
        $iv = substr(md5(random_bytes(16)), 0, 16);
        $encrypted = openssl_encrypt($value, $this->encoding, $this->password, null, $iv);

        return $this->url_encode($iv.$encrypted);
    }
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;
    }
710456
protected function multiple($value)
    {
        $arguments = explode(':', $value);

        if (count($arguments) > 1) {
            $rule = $arguments[0];
            unset($arguments[0]);

            return ['multiple' => true, 'rule' => $rule, 'arguments' => array_values($arguments)];
        }

        return ['multiple' => false];
    }
575733
protected function parseStringsToNativeTypes($value)
    {
        if (is_array($value)) {
            return array_map([$this, 'parseStringsToNativeTypes'], $value);
        }

        if (! is_string($value)) {
            return $value;
        }

        $parsedValue = json_decode($value, true);

        if (json_last_error() === JSON_ERROR_NONE) {
            return $parsedValue;
        }

        return $value;
    }
71920
private function decodeJson($value)
    {
        $decodedValue = json_decode($value, true);
        if (JSON_ERROR_NONE !== json_last_error()) {
            throw new \InvalidArgumentException('JSON parsing error: ' . json_last_error_msg());
        }

        return $decodedValue;
    }
499450
final protected function decode(string $value): string
    {
        $parts = \imap_mime_header_decode($value);
        if (!\is_array($parts)) {
            return $value;
        }

        $decoded = '';
        foreach ($parts as $part) {
            $text = $part->text;
            if ('default' !== $part->charset) {
                $text = Transcoder::decode($text, $part->charset);
            }
            // RFC2231
            if (1 === \preg_match('/^(?<encoding>[^\']+)\'[^\']*?\'(?<urltext>.+)$/', $text, $matches)) {
                $hasInvalidChars = 1 === \preg_match('#[^%a-zA-Z0-9\-_\.\+]#', $matches['urltext']);
                $hasEscapedChars = 1 === \preg_match('#%[a-zA-Z0-9]{2}#', $matches['urltext']);
                if (!$hasInvalidChars && $hasEscapedChars) {
                    $text = Transcoder::decode(\urldecode($matches['urltext']), $matches['encoding']);
                }
            }

            $decoded .= $text;
        }

        return $decoded;
    }
161455
private function deserializeValue($value)
    {
        if (is_array($value) && isset($value['class']) && isset($value['payload'])) {
            return $this->deserializeObjectRecursively($value);
        } elseif (is_array($value)) {
            return $this->deserializeArrayRecursively($value);
        }

        return $value;
    }