mirror of
https://github.com/kvazar-network/keva-stratum.git
synced 2025-01-11 23:58:08 +00:00
24 lines
667 B
Go
24 lines
667 B
Go
package hashing
|
|
|
|
// #cgo CFLAGS: -std=c11 -D_GNU_SOURCE
|
|
// #cgo LDFLAGS: -L${SRCDIR} -lhashing -lstdc++
|
|
// #include <stdlib.h>
|
|
// #include <stdint.h>
|
|
// #include "src/hashing.h"
|
|
import "C"
|
|
import "unsafe"
|
|
|
|
func Hash(blob []byte, fast bool) []byte {
|
|
output := make([]byte, 32)
|
|
if fast {
|
|
C.cryptonight_fast_hash((*C.char)(unsafe.Pointer(&blob[0])), (*C.char)(unsafe.Pointer(&output[0])), (C.uint32_t)(len(blob)))
|
|
} else {
|
|
C.cryptonight_hash((*C.char)(unsafe.Pointer(&blob[0])), (*C.char)(unsafe.Pointer(&output[0])), (C.uint32_t)(len(blob)))
|
|
}
|
|
return output
|
|
}
|
|
|
|
func FastHash(blob []byte) []byte {
|
|
return Hash(append([]byte{byte(len(blob))}, blob...), true)
|
|
}
|