-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from pjbgf/no-cgo-support
build: Support build when CGO is disabled
- Loading branch information
Showing
2 changed files
with
37 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
//go:build !cgo | ||
// +build !cgo | ||
|
||
package cgo | ||
|
||
import ( | ||
"hash" | ||
|
||
"github.com/pjbgf/sha1cd" | ||
"github.com/pjbgf/sha1cd/ubc" | ||
) | ||
|
||
// CalculateDvMask falls back to github.com/pjbgf/sha1cd/ubc implementation | ||
// due to CGO being disabled at compilation time. | ||
func CalculateDvMask(W []uint32) (uint32, error) { | ||
return ubc.CalculateDvMask(W) | ||
} | ||
|
||
// CalculateDvMask falls back to github.com/pjbgf/sha1cd implementation | ||
// due to CGO being disabled at compilation time. | ||
func New() hash.Hash { | ||
return sha1cd.New() | ||
} | ||
|
||
// CalculateDvMask falls back to github.com/pjbgf/sha1cd implementation | ||
// due to CGO being disabled at compilation time. | ||
func Sum(data []byte) ([]byte, bool) { | ||
d := sha1cd.New().(sha1cd.CollisionResistantHash) | ||
d.Write(data) | ||
|
||
return d.CollisionResistantSum(nil) | ||
} |