- Implemented computeSHA256 function to generate hex-encoded SHA256 hashes. - Added verifySHA256 function to validate input data against expected hash in a WebAssembly context. - Created main_test.go to include unit tests for computeSHA256 with various input cases.
14 lines
240 B
Go
14 lines
240 B
Go
package main
|
|
|
|
import (
|
|
"crypto/sha256"
|
|
"encoding/hex"
|
|
)
|
|
|
|
// computeSHA256 returns the hex-encoded SHA256 hash of the input data.
|
|
func computeSHA256(data []byte) string {
|
|
hash := sha256.Sum256(data)
|
|
return hex.EncodeToString(hash[:])
|
|
}
|
|
|