c++ - std::vector 的 sha1 哈希使用加密++
问题描述
我收集了该类型的向量,std::vector<uint8_t>
我需要为每个单独的向量存储一个散列值。我想为此使用crypto++。但我不确定这是否可能。据我所知,如果我把它做成std::vector<byte>
. 但是,我看到的示例也提供了 a 中的哈希值std::vector<byte>
。那么我想用crypto++做些什么还是我需要寻找另一个库?如果是,你能提供一个例子吗?
编辑: 带有字节指针的示例(https://www.cryptopp.com/wiki/User_guide:_cryptlib.h):
byte const* pbData1 = ...;
byte const* pbData2 = ...
unsigned int nData1Len = ...;
unsigned int nData2Len = ...;
byte abDigest[SHA::DIGESTSIZE];
SHA hash;
hash.Update(pbData1, nData1Len);
hash.Update(pbData2, nData2Len);
hash.Final(abDigest);
// abDigest now contains the hash of pbData1 and pbData2;
// the object 'hash' can now be reused to calculate another digest
...
SHA hash;
hash.Update(pbData1, nData1Len);
hash.Update(pbData2, nData2Len);
if (!hash.Verify(abDigest))
throw "abDigest does not contain the right hash";
解决方案
推荐阅读
- apache-spark - 只有 2 台计算机的集群上的 Apache spark
- angular - 即使导出了 Ionic 3,TypeScript 也找不到名称“ClassName”
- python-3.x - 与 `os.system` 语句混合时,`print` 函数在 Python 中不起作用
- php - htmlspecialchars() 期望参数 1 是字符串 (Laravel 5.7.1)
- react-native - 在 react native 中使用 native-base 构建的组件禁用一行?
- python - Keras ImageDataGenerator:为什么我的 CNN 的输出反转了?
- django - 由于无 ID,删除内联项目失败
- json - 如何使用 ARM 模板同时创建多个警报
- adapter - 有什么方法可以解析位图被屏蔽或没有任何位图的 ISO8583 消息?
- swift - 如何保证任何 DispatchQueue(或 OperationQueue)仅在异步任务的非主线程中运行?