예제 #1
0
func MemCmp(buff1, buff2 []byte, length int) int {
	if length >= len(buff1) || length >= len(buff2) {
		panic(fmt.Sprintf("Attempt to compare more bytes (%d) than provided "+
			"(%d, %d)", length, len(buff1), len(buff2)))
	}
	return int(C.sodium_memcmp(unsafe.Pointer(&buff1[0]),
		unsafe.Pointer(&buff2[0]),
		C.size_t(length)))
}
예제 #2
0
func MemCmp(b1, b2 []byte, l int) int {
	if l >= len(b1) || l >= len(b2) {
		panic(fmt.Sprintf("Attempt to compare more bytes (%d) than provided (%d, %d)", l, len(b1), len(b2)))
	}
	return int(C.sodium_memcmp(unsafe.Pointer(&b1[0]), unsafe.Pointer(&b2[0]), C.size_t(l)))
}