簡體   English   中英

crypto++ 庫中的 SHA512 hash 引發異常

[英]SHA512 hash in crypto++ library throws exception

我在 Visual Studio 2010 中構建了 crypto++ 8.4 並制作了一些測試代碼。 它在“Win32|Debug”中運行良好,但在“Win32|Release”中 hash.CalculateDigest 會引發異常。

    string source = "I am a programmer.";

    CryptoPP::SHA512 hash;
    CryptoPP::byte digest[CryptoPP::SHA512::DIGESTSIZE];            
    hash.CalculateDigest(digest, (const CryptoPP::byte*)source.c_str(), source.length());

    string result;  
    CryptoPP::HexEncoder encoder;

    encoder.Attach(new CryptoPP::StringSink(result));
    encoder.Put(digest, sizeof(digest));

發生異常的位置如下。 (sha.cpp) 在此處輸入圖像描述

我做錯了什么?

我發現了一個明確的例外情況。 如果 'hash' 被聲明為指針而不是局部變量,則不會引發異常。

CryptoPP::SHA512 * hash = new CryptoPP::SHA512;

我不知道為什么會這樣,但是對於 SHA512,我懷疑 VS 2010 的 cryptopp 中是否存在 memory 管理問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM