Files
Odin/tests/core/crypto/common/common.odin
2026-04-20 21:34:24 +09:00

26 lines
520 B
Odin

package test_crypto_common
import "core:bytes"
import "core:encoding/hex"
// Common helpers for cryptography tests.
Hex_Bytes :: string
hexbytes_compare :: proc(x: Hex_Bytes, b: []byte, allocator := context.allocator) -> bool {
dst := hexbytes_decode(x)
defer delete(dst)
return bytes.equal(dst, b)
}
hexbytes_decode :: proc(x: Hex_Bytes, allocator := context.allocator) -> []byte {
dst, ok := hex.decode(transmute([]byte)(x), allocator)
if !ok {
panic("Hex_Bytes: invalid hex encoding")
}
return dst
}