Parse the command signature.

@param string $signature
771226
public function parse($signature)
    {
        $this->setName($signature);

        $argumentsOptions = $this->extractArgumentsOptions($signature);

        foreach ($argumentsOptions as $value) {
            if (substr($value, 0, 2) !== '--') {
                $input = new Argument($value);
            } else {
                $input = new Option(trim($value, '--'));
            }

            $this->command->addInput($input->parse());
        }
    }
199083
public function verifySignature($data, $signature)
    {
        switch ($this->cryptParams['library']) {
            case 'openssl':
                return $this->verifyOpenSSL($data, $signature);
            case (self::HMAC_SHA1):
                $expectedSignature = hash_hmac("sha1", $data, $this->key, true);
                return strcmp($signature, $expectedSignature) == 0;
        }
    }
861384
function verify($message, $signature)
    {
        if (empty($this->modulus) || empty($this->exponent)) {
            return false;
        }

        switch ($this->signatureMode) {
            case self::SIGNATURE_PKCS1:
                return $this->_rsassa_pkcs1_v1_5_verify($message, $signature);
            //case self::SIGNATURE_PSS:
            default:
                return $this->_rsassa_pss_verify($message, $signature);
        }
    }
983680
public function assign($signature) {

        $file = $this->path.$this->language.DIRECTORY_SEPARATOR.$signature.'.php';

        // content does not loaded yet
        if(isset($this->required[$file]) === false) {

            if (file_exists($file) === true) {

                $content = include $file;
                $this->required[$file] = true;
            }
            else {
                // set default path by default language
                $file = $this->path.$this->default.DIRECTORY_SEPARATOR.$signature.'.php';
                if (file_exists($file) === true) {

                    $content = include $file;
                    $this->required[$file] = true;
                }
            }

            // assign to translate
            $this->adapter = new TranslateAdapterArray(['content' => [
                    $signature => (isset($content)) ? $content : false
            ]]);
        }

        // $this->adapter->offsetGet() was thrown error with Phalcon 2.0 (??)
        $reflection = new \ReflectionClass($this->adapter);
        $property = $reflection->getProperty('_translate');
        $property->setAccessible(true);
        //$this->signature = $this->adapter->offsetGet($signature);

        // setup signature
        $this->signature = $property->getValue($this->adapter)[$signature];

        return $this;
    }
429357
protected function sign($input)
    {
        // HMAC SHA.
        if (\substr($this->algo, 0, 2) === 'HS') {
            return \hash_hmac($this->algos[$this->algo], $input, $this->key, true);
        }

        $this->validateKey();

        \openssl_sign($input, $signature, $this->key, $this->algos[$this->algo]);

        return $signature;
    }
515484
def get_signature_from_signature_string(self, signature):
        """"""
        match = self.SIGNATURE_RE.search(signature)
        if not match:
            return None
        return match.group(1)
911144
public function getDefinition($signature)
    {
        $elements = $this->meta->parseMany($signature);

        return \array_map([$this->element, 'transform'], $elements);
    }
1236753
function _sign($key, $signatureAlgorithm)
    {
        switch (strtolower(get_class($key))) {
            case 'crypt_rsa':
                switch ($signatureAlgorithm) {
                    case 'md2WithRSAEncryption':
                    case 'md5WithRSAEncryption':
                    case 'sha1WithRSAEncryption':
                    case 'sha224WithRSAEncryption':
                    case 'sha256WithRSAEncryption':
                    case 'sha384WithRSAEncryption':
                    case 'sha512WithRSAEncryption':
                        $key->setHash(preg_replace('#WithRSAEncryption$#', '', $signatureAlgorithm));
                        $key->setSignatureMode(CRYPT_RSA_SIGNATURE_PKCS1);

                        $this->currentCert['signature'] = base64_encode("\0" . $key->sign($this->signatureSubject));
                        return $this->currentCert;
                }
            default:
                return false;
        }
    }
755989
public function parse($text) {
        parent::parse($text);

        $number = self::executeStep1($this->text, $this->barcodeIdentifier, $this->serviceTypeIdentifier, $this->mailerIdentifier, $this->serialNumber);
        $crc = self::executeStep2($number);
        $codewords = self::executeStep3($number);
        $codewords = self::executeStep4($codewords, $crc);
        $characters = self::executeStep5($codewords, $crc);
        $this->data = self::executeStep6($characters);
    }
88396
protected function _sign($parameters)
    {
        // Fixup our private key, copy-pasting the key might lead to whitespace faults
        if (!preg_match('/-----BEGIN (RSA )?PRIVATE KEY-----(.*)-----END (RSA )?PRIVATE KEY-----/si', $this->client->getPrivateKey(), $matches)) {
            die('<p>Could not find your private key, please supply your private key in the ApiSettings file. You can request a new private key in your TransIP Controlpanel.</p>');
        }

        $key = $matches[2];
        $key = preg_replace('/\s*/s', '', $key);
        $key = chunk_split($key, 64, "\n");

        $key = "-----BEGIN PRIVATE KEY-----\n" . $key . "-----END PRIVATE KEY-----";

        $digest = $this->_sha512Asn1($this->_encodeParameters($parameters));
        if (!@openssl_private_encrypt($digest, $signature, $key)) {
            die('<p>Could not sign your request, please supply your private key in the ApiSettings file. You can request a new private key in your TransIP Controlpanel.</p>');
        }

        return base64_encode($signature);
    }
990159
public function mpsDecode($data_encrypted, $signature)
    {
        try {
            $inputParams = [
                'data_encrypted' => $data_encrypted,
                'signature'      => $signature,
            ];
            $this->debug->info(__FUNCTION__, 'Input Params: ' . json_encode($inputParams));
            $movitelMps = new MovitelMps\MovitelMps($this->options);
            $movitelMps->setMovitelPublicKey($this->movitelPublicKey);
            $movitelMps->setMovitelPrivateKey($this->movitelPrivateKey);
            $movitelMps->setCpPublicKey($this->cpPublicKey);
            $movitelMps->setCpPrivateKey($this->cpPrivateKey);
            $response = $movitelMps->decodeResponseFromMps($data_encrypted, $signature);
            $this->debug->info(__FUNCTION__, 'decode Response From Mps: ' . json_encode($response));
            if (isset($response) && $response !== NULL && count($response) > 0) {
                if ($this->nativeSession === TRUE) {
                    $this->debug->info(__FUNCTION__, 'Movitel Set Session MSISDN Native: ' . json_encode($response['msisdn']));
                    Session::setUserdata(self::SESSION_MSISDN_DEFAULT, $response['msisdn']);
                }
                if ($response['msisdn'] == "" || $response['msisdn'] == "GUEST") {
                    // Không nhận diện được thuê bao
                    $mpsResult = [
                        'status' => 1,
                        'msisdn' => NULL
                    ];
                } else {
                    // Nhận diện được thuê bao
                    $mpsResult = [
                        'status'       => 0,
                        'msisdn'       => $response['msisdn'],
                        'request_ip'   => $response['request_ip'],
                        'request_id'   => $response['request_id'],
                        'response_id'  => $response['response_id'],
                        'price'        => $response['price'],
                        'source'       => $response['source'],
                        'command'      => $response['command'],
                        'content_logs' => $response['content_logs']
                    ];
                    if ($this->nativeSession === TRUE) {
                        $this->debug->info(__FUNCTION__, 'set native Session Mps Result');
                        Session::setUserdata(self::SESSION_MPS_RESULT, json_encode($mpsResult));
                    }
                }
                $this->debug->info(__FUNCTION__, 'MPS Result: ' . json_encode($mpsResult));

                return $mpsResult;
            } else {
                $this->debug->info(__FUNCTION__, 'MPS Not Response or Response is Empty');

                return NULL;
            }
        }
        catch (\Exception $e) {
            $message = 'Error File: ' . $e->getFile() . ' - Line: ' . $e->getLine() . ' - Code: ' . $e->getCode() . ' - Message: ' . $e->getMessage();
            $this->debug->error(__FUNCTION__, $message);

            return NULL;
        }
    }
648253
def do_parse(signature)
      packet = nil
      case signature.sigtype
      when Type::BYTE
        packet = read(1).unpack("C")[0]
      when Type::UINT16
        align(2)
        packet = read(2).unpack(@uint16)[0]
      when Type::INT16
        align(2)
        packet = read(2).unpack(@uint16)[0]
        if (packet & 0x8000) != 0
          packet -= 0x10000
        end
      when Type::UINT32, Type::UNIX_FD
        align(4)
        packet = read(4).unpack(@uint32)[0]
      when Type::INT32
        align(4)
        packet = read(4).unpack(@uint32)[0]
        if (packet & 0x80000000) != 0
          packet -= 0x100000000
        end
      when Type::UINT64
        align(8)
        packet_l = read(4).unpack(@uint32)[0]
        packet_h = read(4).unpack(@uint32)[0]
        packet = if @endianness == LIL_END
                   packet_l + packet_h * 2**32
                 else
                   packet_l * 2**32 + packet_h
                 end
      when Type::INT64
        align(8)
        packet_l = read(4).unpack(@uint32)[0]
        packet_h = read(4).unpack(@uint32)[0]
        packet = if @endianness == LIL_END
                   packet_l + packet_h * 2**32
                 else
                   packet_l * 2**32 + packet_h
                 end
        if (packet & 0x8000000000000000) != 0
          packet -= 0x10000000000000000
        end
      when Type::DOUBLE
        align(8)
        packet = read(8).unpack(@double)[0]
      when Type::BOOLEAN
        align(4)
        v = read(4).unpack(@uint32)[0]
        raise InvalidPacketException if ![0, 1].member?(v)
        packet = (v == 1)
      when Type::ARRAY
        align(4)
        # checks please
        array_sz = read(4).unpack(@uint32)[0]
        raise InvalidPacketException if array_sz > 67_108_864

        align(signature.child.alignment)
        raise IncompleteBufferException if @idx + array_sz > @buffy.bytesize

        packet = []
        start_idx = @idx
        while @idx - start_idx < array_sz
          packet << do_parse(signature.child)
        end

        if signature.child.sigtype == Type::DICT_ENTRY
          packet = Hash[packet]
        end
      when Type::STRUCT
        align(8)
        packet = []
        signature.members.each do |elem|
          packet << do_parse(elem)
        end
      when Type::VARIANT
        string = read_signature
        # error checking please
        sig = Type::Parser.new(string).parse[0]
        align(sig.alignment)
        packet = do_parse(sig)
      when Type::OBJECT_PATH
        packet = read_string
      when Type::STRING
        packet = read_string
        packet.force_encoding("UTF-8")
      when Type::SIGNATURE
        packet = read_signature
      when Type::DICT_ENTRY
        align(8)
        key = do_parse(signature.members[0])
        value = do_parse(signature.members[1])
        packet = [key, value]
      else
        raise NotImplementedError,
              "sigtype: #{signature.sigtype} (#{signature.sigtype.chr})"
      end
      packet
    end
498287
protected function parseSignature(array $header, $data)
    {
        if ($data == '' || !isset($header['alg']) || $header['alg'] == 'none') {
            return null;
        }

        $hash = $this->deserializer->fromBase64URL($data);

        return new Signature($hash);
    }
718628
public function setSignature($signature)
    {
        if (!empty($this->signers)) {
            // clear previously set signers
            $swiftMessage = $this->getSwiftMessage();
            foreach ($this->signers as $signer) {
                $swiftMessage->detachSigner($signer);
            }
            $this->signers = [];
        }
        return $this->addSignature($signature);
    }
616598
public function checkSignature($signature, ...$dataToSign)
    {
        if (empty($signature)) {
            throw new SecurityException('Empty signature');
        }

        if (!is_string($signature)) {
            throw new SecurityException('Signature should be a string');
        }

        if ($signature !== $this->getSignatureGenerator()->generate(...$dataToSign)) {
            throw new SecurityException('Invalid signature');
        }
    }
845466
protected function configureUsingFluentDefinition()
    {
        list($name, $arguments, $options) = Parser::parse($this->signature);
        parent::__construct($this->name = $name);
        // After parsing the signature we will spin through the arguments and options
        // and set them on this command. These will already be changed into proper
        // instances of these "InputArgument" and "InputOption" Symfony classes.
        foreach ($arguments as $argument) {
            $this->getDefinition()->addArgument($argument);
        }
        foreach ($options as $option) {
            $this->getDefinition()->addOption($option);
        }
    }
502235
function parse(signature) {
		var pattern = /^(?:void|([a-zA-Z]+!?|\.{3})(?:[:\s]+([a-zA-Z]+)(?:(=)(@)?(.*))?)?)?$/;

		return signature.split(/\s*,\s*/).map(function(argument, index, all) {
			var result = prepareArgument(argument.match(pattern), 'var' + (index + 1));

			if (result.type === false) {
				throw new Error('polymorphic: invalid argument "' + argument + '" in signature "' + signature + '"');
			}
			else if (result.type === '...' && index < all.length - 1) {
				throw new Error('polymorphic: variadic argument must be at end of signature "' + signature + '"');
			}

			return result;
		}).filter(function(argument) {
			//  a type is undefined if it was declared as 'void' or '' (an empty string)
			return argument.type !== undefined;
		});
	}