當前位置: 首頁>>代碼示例>>Golang>>正文


Golang ripemd160.New函數代碼示例

本文整理匯總了Golang中code/google/com/p/go/crypto/ripemd160.New函數的典型用法代碼示例。如果您正苦於以下問題:Golang New函數的具體用法?Golang New怎麽用?Golang New使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了New函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: RimpHash

func RimpHash(in []byte, out []byte) {
	sha := sha256.New()
	sha.Write(in)
	rim := ripemd160.New()
	rim.Write(sha.Sum(nil)[:])
	copy(out, rim.Sum(nil))
}
開發者ID:liudch,項目名稱:gocoin,代碼行數:7,代碼來源:hash.go

示例2: hash160

func hash160(data []byte) []byte {
	sha := sha256.New()
	ripe := ripemd160.New()
	sha.Write(data)
	ripe.Write(sha.Sum(nil))
	return ripe.Sum(nil)
}
開發者ID:n1rvana,項目名稱:go-hdwallet,代碼行數:7,代碼來源:util.go

示例3: Sha256RipeMD160

func Sha256RipeMD160(b []byte) []byte {
	ripe := ripemd160.New()
	sha := sha256.New()
	sha.Write(b)
	ripe.Write(sha.Sum(nil))
	return ripe.Sum(nil)
}
開發者ID:Zoramite,項目名稱:ripple,代碼行數:7,代碼來源:util.go

示例4: GetAddress

// Convert ECC-256 Public Key to an EMP address (raw 25 bytes).
func GetAddress(log chan string, x, y *big.Int) []byte {
	pubKey := elliptic.Marshal(elliptic.P256(), x, y)
	ripemd := ripemd160.New()

	sum := sha512.Sum384(pubKey)
	sumslice := make([]byte, sha512.Size384, sha512.Size384)
	for i := 0; i < sha512.Size384; i++ {
		sumslice[i] = sum[i]
	}

	ripemd.Write(sumslice)
	appender := ripemd.Sum(nil)
	appender = appender[len(appender)-20:]
	address := make([]byte, 1, 1)

	// Version 0x01
	address[0] = 0x01
	address = append(address, appender...)

	sum = sha512.Sum384(address)
	sum = sha512.Sum384(sum[:])

	for i := 0; i < 4; i++ {
		address = append(address, sum[i])
	}

	return address
}
開發者ID:msecret,項目名稱:emp,代碼行數:29,代碼來源:address.go

示例5: SimpleHashFromBinary

// General Convenience
func SimpleHashFromBinary(item interface{}) []byte {
	hasher, n, err := ripemd160.New(), new(int64), new(error)
	wire.WriteBinary(item, hasher, n, err)
	if *err != nil {
		PanicCrisis(err)
	}
	return hasher.Sum(nil)
}
開發者ID:eris-ltd,項目名稱:toadserver,代碼行數:9,代碼來源:simple_tree.go

示例6: Bitmessage

// Bitmessage produces a hash for the provided message using a SHA-512 in the
// first round and a RIPEMD-160 in the second.
func Bitmessage(msg []byte) ([]byte, error) {
	s := sha512.New()
	s.Write(msg)

	r := ripemd160.New()
	r.Write(s.Sum(nil))
	return r.Sum(nil), nil
}
開發者ID:nictuku,項目名稱:bitz,代碼行數:10,代碼來源:msg.go

示例7: BinaryRipemd160

func BinaryRipemd160(o interface{}) []byte {
	hasher, n, err := ripemd160.New(), new(int64), new(error)
	WriteBinary(o, hasher, n, err)
	if *err != nil {
		panic(*err)
	}
	return hasher.Sum(nil)
}
開發者ID:jaekwon,項目名稱:GuppyCamp,代碼行數:8,代碼來源:util.go

示例8: Rimp160AfterSha256

// Returns hash: RIMP160( SHA256( data ) )
func Rimp160AfterSha256(in []byte) (res [20]byte) {
	sha := sha256.New()
	sha.Write(in)
	rim := ripemd160.New()
	rim.Write(sha.Sum(nil)[:])
	copy(res[:], rim.Sum(nil))
	return
}
開發者ID:spartacusX,項目名稱:gocoin,代碼行數:9,代碼來源:hash.go

示例9: execRipemd160

func execRipemd160(ctx *execContext, op Opcode, _ []byte) error {
	if ctx.stack.empty() {
		return errStackItemMissing
	}
	r := ripemd160.New()
	r.Write(ctx.stack.pop())
	ctx.stack.push(r.Sum(nil))
	return nil
}
開發者ID:haowang1013,項目名稱:kaiju,代碼行數:9,代碼來源:execCrypto.go

示例10: Hash

func (part *Part) Hash() []byte {
	if part.hash != nil {
		return part.hash
	} else {
		hasher := ripemd160.New()
		hasher.Write(part.Bytes) // doesn't err
		part.hash = hasher.Sum(nil)
		return part.hash
	}
}
開發者ID:eris-ltd,項目名稱:toadserver,代碼行數:10,代碼來源:part_set.go

示例11: execHash160

func execHash160(ctx *execContext, op Opcode, _ []byte) error {
	if ctx.stack.empty() {
		return errStackItemMissing
	}
	h := sha256.Sum256(ctx.stack.pop())
	r := ripemd160.New()
	r.Write(h[:])
	ctx.stack.push(r.Sum(nil))
	return nil
}
開發者ID:haowang1013,項目名稱:kaiju,代碼行數:10,代碼來源:execCrypto.go

示例12: Sha256RipeMD160

func Sha256RipeMD160(b []byte) ([]byte, error) {
	ripe := ripemd160.New()
	sha := sha256.New()
	if _, err := sha.Write(b); err != nil {
		return nil, err
	}
	if _, err := ripe.Write(sha.Sum(nil)); err != nil {
		return nil, err
	}
	return ripe.Sum(nil), nil
}
開發者ID:robcat,項目名稱:ripple,代碼行數:11,代碼來源:util.go

示例13: SimpleHashFromTwoHashes

func SimpleHashFromTwoHashes(left []byte, right []byte) []byte {
	var n int64
	var err error
	var hasher = ripemd160.New()
	wire.WriteByteSlice(left, hasher, &n, &err)
	wire.WriteByteSlice(right, hasher, &n, &err)
	if err != nil {
		PanicCrisis(err)
	}
	return hasher.Sum(nil)
}
開發者ID:eris-ltd,項目名稱:toadserver,代碼行數:11,代碼來源:simple_tree.go

示例14: 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

示例15: Hash

func (kv KVPair) Hash() []byte {
	hasher, n, err := ripemd160.New(), new(int64), new(error)
	wire.WriteString(kv.Key, hasher, n, err)
	if kvH, ok := kv.Value.(Hashable); ok {
		wire.WriteByteSlice(kvH.Hash(), hasher, n, err)
	} else {
		wire.WriteBinary(kv.Value, hasher, n, err)
	}
	if *err != nil {
		PanicSanity(*err)
	}
	return hasher.Sum(nil)
}
開發者ID:eris-ltd,項目名稱:toadserver,代碼行數:13,代碼來源:simple_tree.go


注:本文中的code/google/com/p/go/crypto/ripemd160.New函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。