public function sign($payload, $key)
    {
        if (!$key instanceof Key) {
            $key = new Key($key);
        }
        $privateKey = $this->keyParser->parsePrivateKey($key->getContent());

        $hash = $this->hash($payload);

        $random = RandomGeneratorFactory::getRandomGenerator();
        $randomK = $random->generate($this->config->getGenerator()->getOrder());

        $signer = new EccSigner($this->adapter);
        $signature = $signer->sign($privateKey, $hash, $randomK);

        return new LcobucciJWTSignature($this->serializer->serialize($signature, $this->config->getSignatureLength()));
    }
public function sign($payload, $key)
    {
        if (!$key instanceof Key) {
            $key = new Key($key);
        }
        $privateKey = $this->keyParser->parsePrivateKey($key->getContent());

        $hash = $this->hash($payload);

        $random = RandomGeneratorFactory::getRandomGenerator();
        $randomK = $random->generate($this->config->getGenerator()->getOrder());

        $signer = new EccSigner($this->adapter);
        $signature = $signer->sign($privateKey, $hash, $randomK);

        return new LcobucciJWTSignature($this->serializer->serialize($signature, $this->config->getSignatureLength()));
    }
public function sign ( $ payload , $ key ) { if ( ! $ key instanceof Key ) { $ key = new Key ( $ key ) ; } $ privateKey = $ this -> keyParser -> parsePrivateKey ( $ key -> getContent ( ) ) ; $ hash = $ this -> hash ( $ payload ) ; $ random = RandomGeneratorFactory :: getRandomGenerator ( ) ; $ randomK = $ random -> generate ( $ this -> config -> getGenerator ( ) -> getOrder ( ) ) ; $ signer = new EccSigner ( $ this -> adapter ) ; $ signature = $ signer -> sign ( $ privateKey , $ hash , $ randomK ) ; return new LcobucciJWTSignature ( $ this -> serializer -> serialize ( $ signature , $ this -> config -> getSignatureLength ( ) ) ) ; }
Returns a signature for given data

@param string $payload
@param Key|string $key

@return LcobucciJWTSignature

@throws InvalidArgumentException When given key is invalid
Returns a signature for given data