2019-02-07 09:04:29 +00:00
|
|
|
// Copyright (C) 2019 Storj Labs, Inc.
|
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
|
|
|
package pkcrypto
|
|
|
|
|
|
|
|
import (
|
2019-03-18 10:55:06 +00:00
|
|
|
"hash"
|
2019-04-04 09:12:08 +01:00
|
|
|
|
|
|
|
sha256 "github.com/minio/sha256-simd"
|
2019-02-07 09:04:29 +00:00
|
|
|
)
|
|
|
|
|
2019-03-18 10:55:06 +00:00
|
|
|
// NewHash returns default hash in storj.
|
2019-04-04 09:12:08 +01:00
|
|
|
func NewHash() hash.Hash {
|
|
|
|
return sha256.New()
|
|
|
|
}
|
2019-03-18 10:55:06 +00:00
|
|
|
|
2019-02-07 09:04:29 +00:00
|
|
|
// SHA256Hash calculates the SHA256 hash of the input data
|
2019-02-07 17:08:52 +00:00
|
|
|
func SHA256Hash(data []byte) []byte {
|
|
|
|
sum := sha256.Sum256(data)
|
|
|
|
return sum[:]
|
2019-02-07 09:04:29 +00:00
|
|
|
}
|