You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
313 B
Go
21 lines
313 B
Go
12 months ago
|
package sha256
|
||
|
|
||
|
import (
|
||
|
// Standard
|
||
|
"crypto/sha256"
|
||
|
)
|
||
|
|
||
|
// Hash
|
||
|
func (Algorithm) Hash(data []byte) ([]byte, error) {
|
||
|
// Hasher
|
||
|
hasher := sha256.New()
|
||
|
// Write To Hasher
|
||
|
_, err := hasher.Write(data)
|
||
|
// Handle Error
|
||
|
if err != nil {
|
||
|
return []byte(""), err
|
||
|
}
|
||
|
// Return Hash
|
||
|
return hasher.Sum(nil), err
|
||
|
}
|