标识符 "unlock" 未定义

Identifier "unlock" is undefined

在此示例代码中

http://botan.randombit.net/manual/fpe.html

我试图在 Visual C++ 托管包装器中使用一种方法,但我一直在 'unlock' 上收到编译错误这是什么? (可能是mutex::unlock)我该如何解决这个错误?

std::vector<byte> sha1(const std::string& acct_name)
   {
   SHA_160 hash;
   hash.update(acct_name);
   return unlock(hash.final());
   }

错误 16 错误 C3861:'unlock':找不到标识符

编辑:我的 Stdafx.h 文件现在看起来像这样,但它仍然没有编译(即使在包含 secmem.h 之后)

#pragma once

#include <botan/botan.h>
#include <botan/fpe_fe1.h>
#include <botan/sha160.h>
#include <botan/secmem.h>
#include <stdexcept>
#include <vector>

编辑:附加信息 - 我使用的 Botan 库版本是 1.10.9 版(最新的稳定版)。我使用 python 脚本编译并且在调试模式下没有排除任何模块(用所有东西构建它)。

本教程使用这个

using namespace Botan;

可能是命名空间问题。您也可以将 Botan 命名空间声明为 "using",或者使用 Botan::unlock 而不是解锁。

我会推荐第二个,即使它看起来更长。值得!

我刚刚查了一下,好像 Botan v. 1.10.9 没有 unlock。你有两个选择。

版本 1.10.9 有另一种 final 方法,您可以在其中传递 byte 的矢量作为参考以获取 return.

类似于:

byte out[hash.output_length()];
hash.final(out);

另一种选择是将 SecureVector 转换为 std::vector

SecureVector<byte> temp = hash.final();
std::vector<byte> ret(temp.begin(), temp.end());

根据我的应用,我会选择一个而不是另一个。

.

以防有人遇到这个问题并且正在使用 Botan 1.11。

SecureVector转换为std::vector的方法unlock在headersecman.h中。 此外,class SHA_160 还有另一个 final 方法,您可以在其中将 std::vector<byte> 作为参数传递以获取输出。使用此方法,您将不需要解锁功能。