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

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

示例1: GetHash

func GetHash(a string) (hash.Hash, error) {
    var h hash.Hash
    switch a {
    case "adler32":
        h = adler32.New()
    case "crc32", "crc32ieee":
        h = crc32.New(crc32.MakeTable(crc32.IEEE))
    case "crc32castagnoli":
        h = crc32.New(crc32.MakeTable(crc32.Castagnoli))
    case "crc32koopman":
        h = crc32.New(crc32.MakeTable(crc32.Koopman))
    case "crc64", "crc64iso":
        h = crc64.New(crc64.MakeTable(crc64.ISO))
    case "crc64ecma":
        h = crc64.New(crc64.MakeTable(crc64.ECMA))
    case "fnv", "fnv32":
        h = fnv.New32()
    case "fnv32a":
        h = fnv.New32a()
    case "fnv64":
        h = fnv.New64()
    case "fnv64a":
        h = fnv.New64a()
    case "hmac", "hmacsha256":
        h = hmac.New(sha256.New, []byte(key))
    case "hmacmd5":
        h = hmac.New(md5.New, []byte(key))
    case "hmacsha1":
        h = hmac.New(sha1.New, []byte(key))
    case "hmacsha512":
        h = hmac.New(sha512.New, []byte(key))
    case "md4":
        h = md4.New()
    case "md5":
        h = md5.New()
    case "ripemd160":
        h = ripemd160.New()
    case "sha1":
        h = sha1.New()
    case "sha224":
        h = sha256.New224()
    case "sha256":
        h = sha256.New()
    case "sha384":
        h = sha512.New384()
    case "sha512":
        h = sha512.New()
    default:
        return nil, errors.New("Invalid algorithm")
    }
    return h, nil
}

开发者ID:patrickmn,项目名称:picugen,代码行数:52,代码来源:picugen.go

示例2: makeHash

func makeHash(name string) hash.Hash {
    switch strings.ToLower(name) {
    case "ripemd160":
        return ripemd160.New()
    case "md4":
        return md4.New()
    case "md5":
        return md5.New()
    case "sha1":
        return sha1.New()
    case "sha256":
        return sha256.New()
    case "sha384":
        return sha512.New384()
    case "sha3-224":
        return sha3.New224()
    case "sha3-256":
        return sha3.New256()
    case "sha3-384":
        return sha3.New384()
    case "sha3-512":
        return sha3.New512()
    case "sha512":
        return sha512.New()
    case "sha512-224":
        return sha512.New512_224()
    case "sha512-256":
        return sha512.New512_256()
    case "crc32-ieee":
        return crc32.NewIEEE()
    case "crc64-iso":
        return crc64.New(crc64.MakeTable(crc64.ISO))
    case "crc64-ecma":
        return crc64.New(crc64.MakeTable(crc64.ECMA))
    case "adler32":
        return adler32.New()
    case "fnv32":
        return fnv.New32()
    case "fnv32a":
        return fnv.New32a()
    case "fnv64":
        return fnv.New64()
    case "fnv64a":
        return fnv.New64a()
    case "xor8":
        return new(xor8)
    case "fletch16":
        return &fletch16{}
    }
    return nil
}

开发者ID:qeedquan,项目名称:misc_utilities,代码行数:51,代码来源:checksum.go

示例3: decStreamHeader

/* Decode the Stream Header field (the first 12 bytes of the .xz Stream). */
func decStreamHeader(s *xzDec) xzRet {
    if string(s.temp.buf[:len(headerMagic)]) != headerMagic {
        return xzFormatError
    }
    if xzCRC32(s.temp.buf[len(headerMagic):len(headerMagic)+2], 0) !=
        getLE32(s.temp.buf[len(headerMagic)+2:]) {
        return xzDataError
    }
    if s.temp.buf[len(headerMagic)] != 0 {
        return xzOptionsError
    }
    /*
     * Of integrity checks, we support none (Check ID = 0),
     * CRC32 (Check ID = 1), CRC64 (Check ID = 4) and SHA256 (Check ID = 10)
     * However, we will accept other check types too, but then the check
     * won't be verified and a warning (xzUnsupportedCheck) will be given.
     */
    s.checkType = xzCheck(s.temp.buf[len(headerMagic)+1])
    if s.checkType > xzCheckMax {
        return xzOptionsError
    }
    switch s.checkType {
    case xzCheckNone:
        // xzCheckNone: no action needed
    case xzCheckCRC32:
        s.check = crc32.New(xzCRC32Table)
    case xzCheckCRC64:
        s.check = crc64.New(xzCRC64Table)
    case xzCheckSHA256:
        s.check = sha256.New()
    default:
        return xzUnsupportedCheck
    }
    return xzOK
}

开发者ID:cardi,项目名称:timefind,代码行数:36,代码来源:dec_stream.go

示例4: NewSpecialCollectionCache

func NewSpecialCollectionCache(intent *intents.Intent, demux *Demultiplexer) *SpecialCollectionCache {
    return &SpecialCollectionCache{
        Intent: intent,
        Demux:  demux,
        hash:   crc64.New(crc64.MakeTable(crc64.ECMA)),
    }
}

开发者ID:Machyne,项目名称:mongo,代码行数:7,代码来源:demultiplexer.go

示例5: UniqID

func (p *onePeer) UniqID() uint64 {
    h := crc64.New(crctab)
    h.Write(p.Ip6[:])
    h.Write(p.Ip4[:])
    h.Write([]byte{byte(p.Port >> 8), byte(p.Port)})
    return h.Sum64()
}

开发者ID:johtso,项目名称:gocoin,代码行数:7,代码来源:peerdb.go

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