Files
edd3aa5cbc net: fix #344 qemu process missing gvproxy config (#352)
* chore: move CGO_ENABLE arg to makefile

* chore: use actual current executable path

* chore: fix generated binary on M1 mac

* net: fix #344 qemu process missing gvproxy config

* chore: update gitignore

* chore: refactor, mock filesystem in tests

* chore: update nix environment

* chore: refactor Makefile (#354)

* refactor: extract build logic from build.sh to Makefile

* chore: add test rule to Makefile

* apply review suggestion

Co-authored-by: Abiola Ibrahim <[email protected]>

* fix: use defined `OUTPUT_DIR` variable

* chore: remove -race flag from test as it needs CGO_ENABLED=1

* chore: generate sha in binaries directory

* chore: propagate Go build environment variables

Co-authored-by: Abiola Ibrahim <[email protected]>

* chore: disable CGO

* chore: remove empty file

Co-authored-by: tricktron <[email protected]>
2022-06-29 08:02:32 +01:00

34 lines
637 B
Go

package shautil
import (
"crypto/sha1"
"crypto/sha256"
"fmt"
)
// SHA is a sha computation
type SHA interface {
String() string
Bytes() []byte
}
type s1 [20]byte
func (s s1) String() string { return fmt.Sprintf("%x", s[:]) }
func (s s1) Bytes() []byte { return s[:] }
type s256 [32]byte
func (s s256) String() string { return fmt.Sprintf("%x", s[:]) }
func (s s256) Bytes() []byte { return s[:] }
// SHA256Hash computes a sha256sum of a string.
func SHA256(s string) SHA {
return s256(sha256.Sum256([]byte(s)))
}
// SHA256Hash computes a sha256sum of a string.
func SHA1(s string) SHA {
return s1(sha1.Sum([]byte(s)))
}