Hi,
I'm quite new to both C++ and crypto++, and have been trying to work out 
this problem.
I've successfully installed crypto++ 5.6.2 to Windows 7 64-bit and Ubuntu 
12.04 64-bit.

Under Ubuntu, my SHA256() function occasionally returns nothing. I can 
reproduce it usually by entering a few large values and then a couple 
small. It works 100% of the time under windows.
g++ version 4.6.3.

Any hints would be appreciated,
Thanks.


   1. I compile with:
   g++ -m32 -O3 -fpic -g -c main.cpp -lcryptopp
   2. g++ -m32 -shared -o test.exe main.o -lc --static -lcryptopp
   
   
   1. #include "cryptopp/sha.h"
      2. #include "cryptopp/base64.h"
      3. #include "cryptopp/hex.h"
      4. #include <iostream>
      5. #include <string>
      6.  
      7. const char * SHA256(const char * argv)
      8. {
      9.     CryptoPP::SHA256 hash;
      10.     byte digest[ CryptoPP::SHA256::DIGESTSIZE ];
      11.     std::string input = std::string(argv);
      12.  
      13.     hash.CalculateDigest( digest, (const byte *)input.c_str(), 
      input.length() );
      14.  
      15.     CryptoPP::HexEncoder encoder;
      16.     std::string output;
      17.     encoder.Attach(new CryptoPP::StringSink( output ));
      18.     encoder.Put( digest, sizeof(digest) );
      19.     encoder.MessageEnd();
      20.     return output.c_str();
      21. }
      22. int main()
      23. {
      24.         std::string str;
      25.         while(1)
      26.         {
      27.                 str.clear();
      28.                 std::getline(std::cin, str);
      29.                 const char * result = SHA256(str.c_str());
      30.                 std::cout << "Hash: " << result << std::endl;
      31.         }
      32.         return 0;
      33. }
      

-- 
-- 
You received this message because you are subscribed to the "Crypto++ Users" 
Google Group.
To unsubscribe, send an email to [email protected].
More information about Crypto++ and this group is available at 
http://www.cryptopp.com.
--- 
You received this message because you are subscribed to the Google Groups 
"Crypto++ Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to