有人告诉我使用 Siphash key
24 64 6d 71 33 45 30 31 63 2f 6d 69 37 33 9d 19
我正在尝试使用 OpenBSD 中的 SipHash24_Init上。
我有以下全局:
const SIPHASH_KEY COMP_SIPHASH_KEY = 0x24646d7133453031632f6d6937339d19;
像这样使用:
SIPHASH_CTX ctx;
SipHash24_Init(&ctx, &COMP_SIPHASH_KEY);
我会发布更多,但它很复杂,我认为它不相关
但是我在定义/声明中遇到以下编译器错误:
error: integer constant is too large for its type
error: invalid initializer
最佳答案
鉴于我最近在 C 方面的实践有限,我认为你应该这样做:
SIPHASH_CTX ctx;
SIPHASH_KEY key;
key.k0 = bswap_64(0x24646d7133453031);
key.k1 = bswap_64(0x632f6d6937339d19);
SipHash24_Init(&ctx, &key);
作为SIPHASH_KEY
似乎定义为
typedef struct {
uint64_t k0;
uint64_t k1;
} SIPHASH_KEY;
我正在使用 <byteswap.h>
这里的库将 long 值中的字节反转为 k0
和 k1
应该被编码为小端值。
关于c - SipHash24 key "too large for its type",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33193972/