示例#1
0
文件: sha256.go 项目: postfix/go-ssl
// New returns a new sha256 hash.Hash
func New() hash.Hash {
	hash := new(SHA256Hash)
	if C.SHA256_Init(&hash.sha) != 1 {
		panic("problem creating hash")
	}
	return hash
}
示例#2
0
文件: sha256.go 项目: runcom/gossl
// New returns a new sha256 hash.Hash
// if the returned hash is empty, then make a call to sslerr.Error()
func New() hash.Hash {
	d := new(digest)
	if C.SHA256_Init(&d.ctx) != 1 {
		return nil
	}
	return d
}
示例#3
0
文件: sha256.go 项目: runcom/gossl
func (d *digest) Reset() {
	if d.is224 {
		C.SHA224_Init(&d.ctx)
		return
	}
	C.SHA256_Init(&d.ctx)
}
示例#4
0
文件: sha2.go 项目: 1lann/krist-miner
func sum256(data []byte) []byte {
	var hash = make([]byte, 65)
	var sha256 C.SHA256_CTX
	C.SHA256_Init(&sha256)
	C.SHA256_Update(&sha256, unsafe.Pointer(&data[0]), C.size_t(len(data)))
	C.SHA256_Final((*C.uchar)(&hash[0]), &sha256)
	return hash[:64]
}
示例#5
0
文件: sha256.go 项目: postfix/go-ssl
func (self *SHA256Hash) Reset() {
	C.SHA256_Init(&self.sha)
}
示例#6
0
文件: sha.go 项目: eftychis/crypto-1
func (h *sha256) Reset() {
	if C.SHA256_Init(&h.ctx) != 1 {
		panic("SHA256_Init failed") // hash funcs shouldn't fail
	}
}