Sign the input with configured key and return the signature.

@param string $input

@return string
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;
    }
1363139
public static function unpad(string $input): string
    {
        // Determine the padding size by converting the final byte of the  
        // input to its decimal value
        $padsize = \ord(Str::substr($input, -1));

        // Return string minus the padding amount
        return Str::substr($input, 0, Str::strlen($input) - $padsize);
    }
479035
private static function signRequest($options = array()) {
    $headers = array();
    $authorizationHeader = "";

    $privateKey = Api::getPrivateKey();
    $keyId = Api::getKeyId();
    $securityBearer = Api::getSecurityBearer();

    if (!empty($privateKey) && !empty($keyId)) {
      $date = date("r");
      array_push($headers, "Date: ".$date);

      $signature = "(request-target): ".strtolower($options["method"])." ".$options["path"]."\n";
      $signature .= "host: ".str_replace("https://", "", Api::getAuthservicesUrl())."\n";
      if (!empty($options["body"])) {
        $digest = base64_encode(hash("sha256", $options["body"], true));
        array_push($headers, "Digest: SHA-256=".$digest);

        $signature .= "content-type: application/json\n";
        $signature .= "content-length: ".strlen($options["body"])."\n";
        $signature .= "digest: SHA-256=$digest\n";
      }
      $signature .= "date: $date";

      openssl_sign($signature, $signedSignature, $privateKey, OPENSSL_ALGO_SHA256);
      $base64SignedSignature = base64_encode($signedSignature);

      $signatureHeaders = "(request-target) host date";
      if (!empty($options["body"])) {
        $signatureHeaders = "(request-target) host content-type content-length digest date";
      }

      $authorizationHeader = "Signature keyId=\"$keyId\", algorithm=\"rsa-sha256\", headers=\"$signatureHeaders\", signature=\"$base64SignedSignature\"";
    } else if (!empty($securityBearer)) {
      $authorizationHeader = "Bearer $securityBearer";
    }

    if (!empty($authorizationHeader)) {
      array_push($headers, "Authorization: $authorizationHeader");
    }

    return array(
      "headers" => $headers
    );
  }
999339
public function encode($input)
    {
        $this->value = base64_encode(
            mcrypt_encrypt(
                MCRYPT_RIJNDAEL_256,
                $this->secureKey,
                $input,
                MCRYPT_MODE_ECB,
                $this->iv
            )
        );

        return $this->value;
    }
842899
private function fromCompactSerializationToSerialization($input)
    {
        $parts = explode('.', $input);
        switch (count($parts)) {
            case 3:
                return $this->fromCompactSerializationSignatureToSerialization($parts);
            case 5:
                return $this->fromCompactSerializationRecipientToSerialization($parts);
            default:
                throw new \InvalidArgumentException('Unsupported input');
        }
    }
1245427
public static function formatStringToMethodName(string $input) : string
    {
        $methodName = implode('', array_map('ucfirst', explode('_', strtolower($input))));

        return $methodName;
    }
1185663
public function canonicalize($input)
    {
        $filtered = preg_replace('/\D+/', '', $input) ?? '';
        if (strlen($filtered) !== $this->digitLength) {
            return $input;
        }

        return $filtered;
    }
269334
protected function encryptMcrypt($input)
    {
        $ivlen = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_CBC);
        $iv    = mcrypt_create_iv($ivlen, MCRYPT_RAND);
        $key   = $this->getEncryptionSaltKey();

        return $iv . mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $input, MCRYPT_MODE_CBC, $iv);
    }
1113276
protected function getSignSalt($string)
    {
        if (($salt = $this->getConfig('sign_salt')) === null) {
            throw new \RuntimeException('Require signature salt');
        }

        if (is_callable($salt) && (!$salt = call_user_func($salt, $string))) {
            throw new \RuntimeException('Salt function return noting');
        }

        if ($this->getConfig('bind_ip')) {
            $ip = $this->getConfig('request')->getClientIP();
            $salt .= long2ip(ip2long($ip) & ip2long('255.255.255.0'));     // 192.168.1.123 -> 192.168.1.0
        }

        return $salt;
    }
375242
public function matched($input)
    {
        if ($this->token instanceof Token) {
            return $this->token->matched($input);
        }
        
        return $input;
    }
779383
private function captureUserAndPassword(Input $input)
    {
        $text = trim(preg_replace('|\W+|', ' ', $input->text));

        return explode(' ', $text);
    }
812149
private function stringToUtf($input)
    {
        if (is_array($input)) {
            $temp = array();
            foreach ($input as $key => $value) {
                $temp[$this->stringToUtf($key)] = $this->stringToUtf($value);
            }
            $input = $temp;
        } elseif (is_string($input)) {
            $input = iconv('iso-8859-15', 'utf-8', $input);
        }

        return $input;
    }
1057498
protected function convertPositiveTo($input)
    {
        $extraLen = strlen($input) - 5;

        if ($extraLen < 0) {
            return str_pad($input, 4, '0', STR_PAD_LEFT);
        }

        if ($extraLen < 26) {
            return chr(static::ORD_START + $extraLen) . $input;
        }

        $extraLen -= 25;

        $prefix = '';
        $carets = '';

        do {
            $carets .= '^';
            $extraLen--;

            $prefix = chr(static::ORD_START + $extraLen % 26) . $prefix;
            $extraLen = intval($extraLen / 26);
        } while ($extraLen);

        return "${carets}${prefix}${input}";
    }
1292171
public function prepare($input)
    {
        $form = $this->buildNestedForm($this->column, $this->builder);

        return $form->setOriginal($this->original, $this->getKeyName())->prepare($input);
    }
1310275
public function verify($key, $signature, $input)
    {
        $signedInput = $this->sign($input, $key);

        return $this->timingSafeEquals($signedInput, $signature);
    }
1196925
public function sign($content) {
        if (is_array($content)) {
            $this->ignoreKeys = ['sign'];
            $content = $this->getSignContent($content);
        }
        if ($this->getSignType() == self::MD5) {
            return md5($content.$this->key);
        }
        return $this->getRsa()->sign($content);
    }
895281
public function convertFromPositive($input)
    {
        $matches = [];

        if (
            !preg_match(
                '
                /^0*(?<carets>\\^*)(?<alpha>[A-Z]*)(?<year>\d+)$/',
                $input,
                $matches
            )
        ) {
            return null;
        }

        if ($matches['alpha'] === '') {
            return $matches['year'];
        }

        if ($matches['carets'] === '') {
            $expectedLength = ord($matches['alpha']) - static::ORD_START + 5;
        } else {
            $len = strlen($matches['carets']);

            $expectedLength = 0;

            for ($i=0; $i < $len; $i++) {
                $expectedLength = $expectedLength * 26;
                $expectedLength += ord($matches['alpha'][$i]) - static::ORD_START;
                $expectedLength++;
            }

            $expectedLength += 30;
        }

        return str_pad($matches['year'], $expectedLength, '0', STR_PAD_RIGHT);
    }