1 // Package sha3pool is a freelist for SHA3-256 hash objects.
7 "golang.org/x/crypto/sha3"
10 var pool = &sync.Pool{New: func() interface{} { return sha3.New256() }}
12 // Get256 returns an initialized SHA3-256 hash ready to use.
13 // It is like sha3.New256 except it uses the freelist.
14 // The caller should call Put256 when finished with the returned object.
15 func Get256() sha3.ShakeHash {
16 return pool.Get().(sha3.ShakeHash)
19 // Put256 resets h and puts it in the freelist.
20 func Put256(h sha3.ShakeHash) {
25 // Sum256 uses a ShakeHash from the pool to sum into hash.
26 func Sum256(hash, data []byte) {