Пример #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
	}
}
Пример #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)
}
Пример #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
		})
	}

}
Пример #4
0
func init() {
	crypto.RegisterHash(crypto.SHA1, New)
}
Пример #5
0
Файл: md5.go Проект: gmwu/go
func init() {
	crypto.RegisterHash(crypto.MD5, New)
}
Пример #6
0
func init() {
	crypto.RegisterHash(crypto.RIPEMD160, New)
}
Пример #7
0
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)
}
Пример #8
0
func init() {
	crypto.RegisterHash(crypto.SHA224, New224)
	crypto.RegisterHash(crypto.SHA256, New)
}
Пример #9
0
func init() {
	crypto.RegisterHash(crypto.SHA384, New384)
	crypto.RegisterHash(crypto.SHA512, New)
}
Пример #10
0
func init() {
	crypto.RegisterHash(crypto.MD5, New) // 将md5注册进crypto
}
Пример #11
0
func init() {
	crypto.RegisterHash(crypto.SHA1, New) // 注册SHA1 HASH函数
}