【发布时间】:2019-06-23 21:25:41
【问题描述】:
我正在尝试编写一个以 Botan 作为后端的哈希函数:
std::string hex_hash(std::string &in, const std::string &HASH)
{
std::unique_ptr<Botan::HashFunction> hash(Botan::HashFunction::create(HASH));
return Botan::hex_encode(hash->process(in));
}
HASH 是一个std::string,它是请求的哈希的名称。即"SHA-512" 用于 SHA512,"BLAKE2b" 用于 BLAKE2b
botan 支持的任何其他哈希都会被处理和输出,但 BLAKE2b 不会并抛出异常:
Exception thrown at 0x00007FF661382C5A in test.exe: 0xC0000005: Access violation reading location 0x0000000000000000.
然后崩溃。
我确实在 botan (https://botan.randombit.net/manual/hash.html) 的手册中注意到
布莱克2b
在定义 BOTAN_HAS_BLAKE2B 时可用。
最近设计的哈希函数。在 64 位处理器上非常快。可以输出 1 到 64 字节之间任意长度的散列,这是通过将值传递给具有所需长度的构造函数来指定的。
是否可能没有默认设置?我将如何设置它?会不会是我的名字错了?
【问题讨论】: