// 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 }
// 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 }
func (d *digest) Reset() { if d.is224 { C.SHA224_Init(&d.ctx) return } C.SHA256_Init(&d.ctx) }
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] }
func (self *SHA256Hash) Reset() { C.SHA256_Init(&self.sha) }
func (h *sha256) Reset() { if C.SHA256_Init(&h.ctx) != 1 { panic("SHA256_Init failed") // hash funcs shouldn't fail } }