本文整理汇总了Golang中hash/crc32.ChecksumIEEE函数的典型用法代码示例。如果您正苦于以下问题:Golang ChecksumIEEE函数的具体用法?Golang ChecksumIEEE怎么用?Golang ChecksumIEEE使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了ChecksumIEEE函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: hashKey

func (c *Consistent) hashKey(key string) uint32 {
    if len(key) < 64 {
        copy(c.scratch[:], key)
        return crc32.ChecksumIEEE(c.scratch[:len(key)])
    }
    return crc32.ChecksumIEEE([]byte(key))
}

开发者ID:postfix,项目名称:consistent,代码行数:7,代码来源:consistent.go

示例2: compareFiles

func compareFiles(srcPath, destPath string) (bool, error) {
    src, err := os.Open(srcPath)
    if err != nil {
        return false, fmt.Errorf("open source failed: %s", err)
    }
    defer src.Close()

    dest, err := os.Open(destPath)
    if err != nil {
        return false, fmt.Errorf("open dest failed: %s", err)
    }
    defer dest.Close()

    srcContents, err := ioutil.ReadAll(src)
    if err != nil {
        return false, fmt.Errorf("read source failed: %s", err)
    }
    destContents, err := ioutil.ReadAll(dest)
    if err != nil {
        return false, fmt.Errorf("read dest failed: %s", err)
    }

    contentsHash := fmt.Sprintf("%x", crc32.ChecksumIEEE(srcContents))
    srcHash := fmt.Sprintf("%x", crc32.ChecksumIEEE(destContents))

    return srcHash == contentsHash, nil
}

开发者ID:ernestoalejo,项目名称:cb,代码行数:27,代码来源:init.go

示例3: Apply

// Apply applies the patch data to the given base.
func Apply(base []byte, patch *common.PatchData, skipCRC bool) ([]byte, error) {
    if uint64(len(base)) != patch.InputFileSize {
        return nil, errors.New("Base file did not have expected size.")
    }
    if !skipCRC && crc32.ChecksumIEEE(base) != patch.InputChecksum {
        return nil, errors.New("Base file did not have expected checksum")
    }

    output := make([]byte, patch.OutputFileSize)
    copy(output, base)

    pointer := 0
    for _, block := range patch.PatchBlocks {
        pointer += int(block.RelativeOffset)

        for _, b := range block.Data {
            if pointer >= len(base) {
                output[pointer] = b
            } else {
                output[pointer] = base[pointer] ^ b
            }
            pointer++
        }

        pointer++
    }

    if !skipCRC && crc32.ChecksumIEEE(output) != patch.OutputChecksum {
        return nil, errors.New("Patch result did not have expected checksum")
    }

    return output, nil
}

开发者ID:rameshvarun,项目名称:ups,代码行数:34,代码来源:apply.go

示例4: getCrc

func getCrc(key string) uint32 {
    if len(key) < 64 {
        var scratch [64]byte
        copy(scratch[:], key)
        return crc32.ChecksumIEEE(scratch[:len(key)])
    }
    return crc32.ChecksumIEEE([]byte(key))
}

开发者ID:wujunjian,项目名称:go,代码行数:8,代码来源:tagflush.go

示例5: hashStr

// Hash function
func (c *Consistent) hashStr(key string) uint32 {
    if len(key) < 64 {
        var scratch [64]byte
        copy(scratch[:], key)
        return crc32.ChecksumIEEE(scratch[:len(key)])
    }
    return crc32.ChecksumIEEE([]byte(key))
}

开发者ID:MingxiaoGuo,项目名称:CMPE273—Lab3,代码行数:9,代码来源:hash.go

最后编辑: kuteng  文档更新时间: 2021-08-23 19:14   作者:kuteng