Esempio n. 1
0
func init() {
	hash2Name[crypto.SHA256] = "sha256"
	hash2Name[crypto.SHA512] = "sha512"
	crypto.RegisterHash(crypto.SHA256, sha256.New)
	crypto.RegisterHash(crypto.SHA512, sha512.New)
	for h, n := range hash2Name {
		name2Hash[n] = h
	}
}
Esempio n. 2
0
func main() {
	m := md5.New()
	str := "test"
	m.Write([]byte(str))
	fmt.Printf("%x\n", m.Sum(nil))

	crypto.RegisterHash(crypto.MD5, md5.New)
	fmt.Println(crypto.MD5.Available())
	cm := crypto.MD5.New()
	cm.Write([]byte(str))
	//fmt.Printf("%x\n", cm.Sum(nil))
	fmt.Printf("%x\n", cm.Sum([]byte("test")))
	fmt.Printf("TestFlag0:%d,TestFlag1:%d,TestFlag2:%d,TestFlag3:%d\n", TestFlag0, TestFlag1, TestFlag2, TestFlag3)
}
Esempio n. 3
0
//RegisterHashes uses go's pluggable hash registry to add gocryptodev
//hashes as the default hash implementation.
func RegisterHashes() {
	digest, err := New(CRYPTO_MD5)
	if err != nil {
		crypto.RegisterHash(crypto.MD5, func() hash.Hash {
			return digest
		})
	}
	digest, err = New(CRYPTO_SHA1)
	if err == nil {
		crypto.RegisterHash(crypto.SHA1, func() hash.Hash {
			return digest
		})
	}
	digest, err = New(CRYPTO_SHA2_256)
	if err == nil {
		crypto.RegisterHash(crypto.SHA256, func() hash.Hash {
			return digest
		})
	}
	digest, err = New(CRYPTO_SHA2_384)
	if err == nil {
		crypto.RegisterHash(crypto.SHA384, func() hash.Hash {
			return digest
		})
	}
	digest, err = New(CRYPTO_SHA2_512)
	if err == nil {
		crypto.RegisterHash(crypto.SHA512, func() hash.Hash {
			return digest
		})
	}
	digest, err = New(CRYPTO_RIPEMD160)
	if err == nil {
		crypto.RegisterHash(crypto.RIPEMD160, func() hash.Hash {
			return digest
		})
	}

}
Esempio n. 4
0
func init() {
	crypto.RegisterHash(crypto.SHA1, New)
}
Esempio n. 5
0
File: md5.go Progetto: gmwu/go
func init() {
	crypto.RegisterHash(crypto.MD5, New)
}
Esempio n. 6
0
func init() {
	crypto.RegisterHash(crypto.RIPEMD160, New)
}
Esempio n. 7
0
File: sha512.go Progetto: 2thetop/go
func init() {
	crypto.RegisterHash(crypto.SHA384, New384)
	crypto.RegisterHash(crypto.SHA512, New)
	crypto.RegisterHash(crypto.SHA512_224, New512_224)
	crypto.RegisterHash(crypto.SHA512_256, New512_256)
}
Esempio n. 8
0
func init() {
	crypto.RegisterHash(crypto.SHA224, New224)
	crypto.RegisterHash(crypto.SHA256, New)
}
Esempio n. 9
0
func init() {
	crypto.RegisterHash(crypto.SHA384, New384)
	crypto.RegisterHash(crypto.SHA512, New)
}
Esempio n. 10
0
func init() {
	crypto.RegisterHash(crypto.MD5, New) // 将md5注册进crypto
}
Esempio n. 11
0
func init() {
	crypto.RegisterHash(crypto.SHA1, New) // 注册SHA1 HASH函数
}