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);
    }