29 lines
594 B
Go
29 lines
594 B
Go
package alph
|
|
|
|
/*
|
|
#cgo CFLAGS : -I../include
|
|
#cgo LDFLAGS: -L../lib -lalph
|
|
|
|
#include <stdlib.h>
|
|
#include "../include/alph.h"
|
|
*/
|
|
import "C"
|
|
import (
|
|
"unsafe"
|
|
)
|
|
|
|
// 计算哈希并返回错误(如果有)
|
|
func computeHash(input []byte) []byte {
|
|
output := make([]byte, 32) // 假设输出长度为 32 字节,根据你的实际情况调整
|
|
|
|
// 调用 C 函数 alph_hash
|
|
C.alph_hash((*C.uchar)(unsafe.Pointer(&output[0])), (*C.uchar)(unsafe.Pointer(&input[0])))
|
|
|
|
return output
|
|
}
|
|
|
|
// Hash 用于对外提供的哈希计算接口
|
|
func Hash(input []byte) []byte {
|
|
return computeHash(input)
|
|
}
|