File: fallback_no_cgo.go

package info (click to toggle)
golang-github-pjbgf-sha1cd 0.3.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 7,576 kB
  • sloc: ansic: 2,188; asm: 1,527; makefile: 28
file content (32 lines) | stat: -rw-r--r-- 764 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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 [80]uint32) uint32 {
	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)
}