diff --git a/cgo/sha1.go b/cgo/sha1.go index dc8d21b..b32dada 100644 --- a/cgo/sha1.go +++ b/cgo/sha1.go @@ -65,3 +65,14 @@ func Sum(data []byte) ([]byte, bool) { return d.sum() } + +func (d *digest) Write(p []byte) (nn int, err error) { + if len(p) == 0 { + return 0, nil + } + + data := (*C.char)(unsafe.Pointer(&p[0])) + C.SHA1DCUpdate(&d.ctx, data, (C.size_t)(len(p))) + + return len(p), nil +} diff --git a/cgo/sha1_nix.go b/cgo/sha1_nix.go deleted file mode 100644 index 447e939..0000000 --- a/cgo/sha1_nix.go +++ /dev/null @@ -1,22 +0,0 @@ -//go:build !windows && !arm -// +build !windows,!arm - -package cgo - -// #include -// #include -// #include -import "C" - -import "unsafe" - -func (d *digest) Write(p []byte) (nn int, err error) { - if len(p) == 0 { - return 0, nil - } - - data := (*C.char)(unsafe.Pointer(&p[0])) - C.SHA1DCUpdate(&d.ctx, data, (C.ulong)(len(p))) - - return len(p), nil -} diff --git a/cgo/sha1_nix_armhf.go b/cgo/sha1_nix_armhf.go deleted file mode 100644 index 80e3836..0000000 --- a/cgo/sha1_nix_armhf.go +++ /dev/null @@ -1,22 +0,0 @@ -//go:build !windows && arm -// +build !windows,arm - -package cgo - -// #include -// #include -// #include -import "C" - -import "unsafe" - -func (d *digest) Write(p []byte) (nn int, err error) { - if len(p) == 0 { - return 0, nil - } - - data := (*C.char)(unsafe.Pointer(&p[0])) - C.SHA1DCUpdate(&d.ctx, data, (C.uint)(len(p))) - - return len(p), nil -} diff --git a/cgo/sha1_windows.go b/cgo/sha1_windows.go deleted file mode 100644 index 37f985b..0000000 --- a/cgo/sha1_windows.go +++ /dev/null @@ -1,22 +0,0 @@ -//go:build windows -// +build windows - -package cgo - -// #include -// #include -// #include -import "C" - -import "unsafe" - -func (d *digest) Write(p []byte) (nn int, err error) { - if len(p) == 0 { - return 0, nil - } - - data := (*C.char)(unsafe.Pointer(&p[0])) - C.SHA1DCUpdate(&d.ctx, data, (C.ulonglong)(len(p))) - - return len(p), nil -}