本文整理汇总了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[:]
}
示例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))
}
示例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
}
示例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)
}
示例5: ripemd160
func (e *Engine) ripemd160() error {
data, err := computeHash(ripemd160.New(), e.stack.Pop())
if err == nil {
e.stack.Push(data)
}
return err
}
示例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
}
示例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)
}
示例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
}
示例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
}
示例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)
}
示例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
}
示例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)
}
示例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]
}
示例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
}
}
示例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)
}