当前位置: 首页>>代码示例>>Golang>>正文


Golang ripemd160.New函数代码示例

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


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

示例1: RIPEMD160Hash

func RIPEMD160Hash(data []byte) []byte {
	first := sha256.Sum256(data)
	hasher := ripemd160.New()
	hasher.Write(first[:])
	hash := hasher.Sum(nil)
	return hash[:]
}
开发者ID:runeaune,项目名称:bitcoin-wallet,代码行数:7,代码来源:hashing.go

示例2: 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:wchh,项目名称:gocoin,代码行数:7,代码来源:hash.go

示例3: hashCalc

func (otp *OTP) hashCalc(algorithm string) ([8]byte, error) {
	var hash_algorithm hash.Hash

	tmpseq := STAITC_OTP_OTP_REP_COUNT - (otp.seq % STAITC_OTP_OTP_REP_COUNT)
	_string_ := strconv.Itoa(otp.seed) + otp.passphrase

	switch otp.mAlgorithm {
	case "MD4":
		hash_algorithm = md4.New()
	case "MD5":
		hash_algorithm = md5.New()
	case "RIPEMD128":
		hash_algorithm = ripemd128.New()
	case "RIPEMD160":
		hash_algorithm = ripemd160.New()
	case "SHA1":
		hash_algorithm = sha1.New()
	default:
		return [8]byte{0, 0, 0, 0, 0, 0, 0, 0}, fmt.Errorf("NoSuchAlgorithmException: %s", otp.mAlgorithm)
	}

	hash_algorithm.Reset()
	hash_algorithm.Write(UCS2_to_UTF8([]byte(_string_)))
	otp.hash = hashValueTo8(hash_algorithm.Sum(nil))

	for tmpseq > 0 {
		hash_algorithm.Reset()
		hash_algorithm.Write(otp.hash[:])
		otp.hash = hashValueTo8(hash_algorithm.Sum(nil))
		tmpseq--
	}

	return otp.hash, nil
}
开发者ID:yamachu,项目名称:srpotp,代码行数:34,代码来源:srp_otpgen.go

示例4: Hash160

// Hash160 computes RIPEMD-160(SHA-256(data))
func Hash160(data []byte) []byte {
	sha2 := sha256.New()
	sha2.Write(data)
	ripemd := ripemd160.New()
	ripemd.Write(sha2.Sum(nil))
	return ripemd.Sum(nil)
}
开发者ID:bfix,项目名称:gospel,代码行数:8,代码来源:hash.go

示例5: ripemd160

func (e *Engine) ripemd160() error {
	data, err := computeHash(ripemd160.New(), e.stack.Pop())
	if err == nil {
		e.stack.Push(data)
	}
	return err
}
开发者ID:ancientlore,项目名称:hashsrv,代码行数:7,代码来源:hash.go

示例6: GetAddress

//GetAddress returns bitcoin address from PublicKey
func (pub *PublicKey) GetAddress() (string, []byte) {
	var publicKeyPrefix byte

	if pub.isTestnet {
		publicKeyPrefix = 0x6F
	} else {
		publicKeyPrefix = 0x00
	}

	//Next we get a sha256 hash of the public key generated
	//via ECDSA, and then get a ripemd160 hash of the sha256 hash.
	var shadPublicKeyBytes [32]byte
	if pub.isCompressed {
		shadPublicKeyBytes = sha256.Sum256(pub.key.SerializeCompressed())

	} else {
		shadPublicKeyBytes = sha256.Sum256(pub.key.SerializeUncompressed())
	}

	ripeHash := ripemd160.New()
	ripeHash.Write(shadPublicKeyBytes[:])
	ripeHashedBytes := ripeHash.Sum(nil)

	publicKeyEncoded := base58check.Encode(publicKeyPrefix, ripeHashedBytes)
	return publicKeyEncoded, ripeHashedBytes
}
开发者ID:utamaro,项目名称:gocoin,代码行数:27,代码来源:keys.go

示例7: 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:askk,项目名称:ripple,代码行数:7,代码来源:util.go

示例8: GenerateSin

func GenerateSin(pubkey []byte) string {

	// FIRST STEP - COMPLETE
	sha_256 := sha256.New()
	sha_256.Write(pubkey)

	// SECOND STEP - COMPLETE
	rip := ripemd160.New()
	rip.Write(sha_256.Sum(nil))

	// THIRD STEP - COMPLETE
	sin_version, _ := hex.DecodeString("0f02")
	pubPrefixed := append(sin_version, rip.Sum(nil)...)

	// FOURTH STEP - COMPLETE
	sha2nd := sha256.New()
	sha2nd.Write([]byte(pubPrefixed))

	sha3rd := sha256.New()
	sha3rd.Write([]byte(sha2nd.Sum(nil)))

	// // FIFTH STEP - COMPLETE
	checksum := sha3rd.Sum(nil)[0:4]

	// SIXTH STEP - COMPLETE
	pubWithChecksum := append(pubPrefixed, checksum...)

	// SIN
	sin := base58.Encode(pubWithChecksum)

	return sin
}
开发者ID:gildo,项目名称:bitcoin-identity,代码行数:32,代码来源:btc-identity.go

示例9: hash20

// ripemd160
func hash20(input []byte) (res *[20]byte) {
	hasher := ripemd160.New()
	hasher.Write(input) // does not error
	resSlice := hasher.Sum(nil)
	res = new([20]byte)
	copy(res[:], resSlice)
	return
}
开发者ID:zramsay,项目名称:geth-tmsp,代码行数:9,代码来源:secret_connection.go

示例10: BinaryRipemd160

// NOTE: The default hash function is Ripemd160.
func BinaryRipemd160(o interface{}) []byte {
	hasher, n, err := ripemd160.New(), new(int), new(error)
	WriteBinary(o, hasher, n, err)
	if *err != nil {
		PanicSanity(*err)
	}
	return hasher.Sum(nil)
}
开发者ID:tendermint,项目名称:go-wire,代码行数:9,代码来源:util.go

示例11: ripemd160ofHexString

func ripemd160ofHexString(hexa string) string {
	byta, _ := hex.DecodeString(hexa)
	hash := ripemd160.New()
	hash.Write(byta)
	hashsum := hash.Sum(nil)
	hexb := hex.EncodeToString(hashsum)
	return hexb
}
开发者ID:philosodad,项目名称:bitpay-go,代码行数:8,代码来源:key_utils.go

示例12: SimpleHashFromBinary

// General Convenience
func SimpleHashFromBinary(item interface{}) []byte {
	hasher, n, err := ripemd160.New(), new(int), new(error)
	wire.WriteBinary(item, hasher, n, err)
	if *err != nil {
		PanicCrisis(err)
	}
	return hasher.Sum(nil)
}
开发者ID:zramsay,项目名称:geth-tmsp,代码行数:9,代码来源:simple_tree.go

示例13: GetFingerPrint

//Extended keys can be identified by the Hash160 (RIPEMD160 after SHA256)
//of the serialized ECSDA public key K, ignoring the chain code
//The first 32 bits of the identifier are called the key fingerprint.
func (pek *ExtendedPublicKey) GetFingerPrint() []byte {
	sha_256 := sha256.New()
	sha_256.Write(pek.PublicKey)
	sha := sha_256.Sum(nil)
	ripemd := ripemd160.New()
	ripemd.Write(sha)
	final := ripemd.Sum(nil)

	return final[:4]
}
开发者ID:21JD21,项目名称:Bitcoin-HD-Wallet-Key-Derivation,代码行数:13,代码来源:HDWallet.go

示例14: 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,项目名称:tendermint,代码行数:10,代码来源:part_set.go

示例15: checkUrlIsCached

func checkUrlIsCached(url string) (string, bool) {
	// check if file is in cache
	cdir := filepath.Join(getArriccioDir(), "cache")
	h := ripemd160.New()
	h.Write([]byte(url))
	hh := h.Sum(nil)
	fname := filepath.Join(cdir, hex.EncodeToString(hh[:]))
	_, err := os.Stat(fname)
	return fname, (err == nil)
}
开发者ID:urs-of-the-backwoods,项目名称:fresco,代码行数:10,代码来源:main.go


注:本文中的golang.org/x/crypto/ripemd160.New函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。