ParagonIE\Halite\Structure\Node::getHash PHP Method

getHash() public method

Get a hash of the data (defaults to hex encoded)
public getHash ( boolean $raw = false, integer $outputSize = Sodium\CRYPTO_GENERICHASH_BYTES, string $personalization = '' ) : string
$raw boolean These two aren't really meant to be used externally:
$outputSize integer
$personalization string
return string
    public function getHash(bool $raw = false, int $outputSize = \Sodium\CRYPTO_GENERICHASH_BYTES, string $personalization = '') : string
    {
        if ($raw) {
            return Util::raw_hash($personalization . $this->data, $outputSize);
        }
        return Util::hash($personalization . $this->data, $outputSize);
    }

Usage Example

Beispiel #1
0
 public function testHash()
 {
     $stringData = \random_bytes(32);
     $hash = \Sodium\crypto_generichash($stringData);
     $node = new Node($stringData);
     $this->assertSame($stringData, $node->getData());
     $this->assertSame($hash, $node->getHash(true));
 }