c++ - 如何将两个字节 * (secblock) 与运算符 'secblock<T, A>::operator+=' 连接起来

标签 c++ crypto++ allocator

请举个例子。我试过在文档中使用它,但我不明白如何使用。

消息:

main.cpp|97|error: no matching function for call to 
   'CryptoPP::SecBlock<unsigned char>::operator+=(CryptoPP::SecBlock<unsigned char>*)'
   secblock.h|568|note: candidate: 
   CryptoPP::SecBlock<T, A>& CryptoPP::SecBlock<T, A>::operator+=(const CryptoPP::SecBlock<T, A>&)
   [with T = unsigned char; A = CryptoPP::AllocatorWithCleanup<unsigned char>]
   secblock.h|568|note:   
   no known conversion for argument 1 from 'CryptoPP::SecBlock<unsigned char>*' 
   to 'const CryptoPP::SecBlock<unsigned char>&'

我的代码:

SecBlock<byte, AllocatorWithCleanup<byte> > hash_ripemd160_temp;
  RIPEMD160().CalculateDigest(hash_ripemd160_temp, hash_sha256, 32);

  SecBlock<byte, AllocatorWithCleanup<byte> > hash_ripemd160 = L0_byte;

   hash_ripemd160 = SecBlock< byte , AllocatorWithCleanup<byte > >::operator+= (&hash_ripemd160_temp);

在文档中是这样的:

SecBlock<byte , AllocatorWithCleanup<byte > >& SecBlock< byte , AllocatorWithCleanup<byte > >::operator+= (const SecBlock< byte , AllocatorWithCleanup<byte > > &t)     
Append contents from another SecBlock.

Parameters

t   the other SecBlock

Internally, this SecBlock calls Grow and then copies the new content.

If the memory block is reduced in size, then the unused area is set to 0.

文件 secblock.h 第 568 行的定义。

最佳答案

调用运算符函数最简单的方法是只使用运算符:

  hash_ripemd160 += hash_ripemd160_temp;

如果你想直接调用它(我不推荐)你必须这样调用它,因为它是一个成员函数:

hash_ripemd160.operator += (hash_ripemd160_temp);

关于c++ - 如何将两个字节 * (secblock) 与运算符 'secblock<T, A>::operator+=' 连接起来,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34479894/

相关文章:

c++ - -bash ./foo : No such file or directory after compilation

c# - C++ 和 C# 在数学方面的性能差异

c++ - Eclipse与Crypto++的合作

c++ - 如何在 32 位机器上将 100G 整数插入到 vector 中?

C++ 内存分配器和多态类型

c++ - 在Qt中模拟全局按键

c++ - Botan:序列化ECDH私钥

c++ - 与 XTR-DH Crypto++ 的 key 协议(protocol)

c++ - AES-128 CBC 模式下加密流末尾的 Crypto++ 额外 block

c++ - 使用不兼容的分配器复制分配无序映射