public static function hash($algo, $data, $returnRaw = false)
    {
        // shortcuts + use Buffer always
        $data = self::prepareInputBuffer($data);

        if (in_array($algo, hash_algos())) {
            // use PHP hash()
            $hash = hash($algo, $data->getBinary(), true);
        }
        elseif (strpos(strtolower($algo), "keccak-") !== false) {
            // use Keccak instead of PHP hash()
            $hash = KeccakHasher::hash($algo, $data->getBinary(), true);
        }
        else {
            throw new RuntimeException("Unsupported hash algorithm '" . $algo . "'.");
        }

        if ((bool) $returnRaw) {
            return $hash;
        }

        return new Buffer($hash);
    }
public static function hash($algo, $data, $returnRaw = false)
    {
        // shortcuts + use Buffer always
        $data = self::prepareInputBuffer($data);

        if (in_array($algo, hash_algos())) {
            // use PHP hash()
            $hash = hash($algo, $data->getBinary(), true);
        }
        elseif (strpos(strtolower($algo), "keccak-") !== false) {
            // use Keccak instead of PHP hash()
            $hash = KeccakHasher::hash($algo, $data->getBinary(), true);
        }
        else {
            throw new RuntimeException("Unsupported hash algorithm '" . $algo . "'.");
        }

        if ((bool) $returnRaw) {
            return $hash;
        }

        return new Buffer($hash);
    }
public static function hash ( $ algo , $ data , $ returnRaw = false ) { // shortcuts + use Buffer always $ data = self :: prepareInputBuffer ( $ data ) ; if ( in_array ( $ algo , hash_algos ( ) ) ) { // use PHP hash() $ hash = hash ( $ algo , $ data -> getBinary ( ) , true ) ; } elseif ( strpos ( strtolower ( $ algo ) , "keccak-" ) !== false ) { // use Keccak instead of PHP hash() $ hash = KeccakHasher :: hash ( $ algo , $ data -> getBinary ( ) , true ) ; } else { throw new RuntimeException ( "Unsupported hash algorithm '" . $ algo . "'." ) ; } if ( ( bool ) $ returnRaw ) { return $ hash ; } return new Buffer ( $ hash ) ; }
Helper to hash the provided buffer `data`'s content
with algorithm `algo`.

The hash algorithm can contain `keccak-256` for example.

@param   string                     $algo
@param   string|\NEM\Core\Buffer    $data
@param   boolean                    $returnRaw
@return  \NEM\Core\Buffer
Helper to hash the provided buffer data s content with algorithm algo .