Hi Jeff,
Thanks for taking the time to reply, unfortunately, the linked wiki article
seems to be incomplete (you would need to include hex.h for HexEncoder or
else you get g++ complaining about HexEncoder not being a member of
CryptoPP)
Even after adding that header to the code it still gives a compile error
complaning that CryptoPP::MD5 has not been declared.
As before here is the code I tried (pretty much a copy of the code from
that wiki + some slight additions (iostream, hex.h, stream)
Many thanks again!
~Leigh
#include <iostream>
#include <string>
#define CRYPTOPP_ENABLE_NAMESPACE_WEAK 1
#include <crypto++/md5.h>
#include <crypto++/hex.h>
int main()
{
byte digest[ CryptoPP::MD5::DIGESTSIZE ];
std::string message = "foobarbat";
CryptoPP::Weak::MD5 hash;
hash.CalculateDigest( digest, (byte*) message.c_str(), message.length()
);
CryptoPP::HexEncoder encoder;
std::string output;
encoder.Attach( new CryptoPP::StringSink( output ) );
encoder.Put( digest, sizeof(digest) );
encoder.MessageEnd();
return 0;
}
and I tried to compile it using this command
g++ -std=c++11 -I/usr/local/include -lcrypto++ cpp-md5sum.cpp -o cpp-md5sum
getting the error:
$ g++ -std=c++11 -I/usr/local/include -lcrypto++ cpp-md5sum.cpp -o
cpp-md5sum
cpp-md5sum.cpp: In function ‘int main()’:
cpp-md5sum.cpp:11:28: error: ‘CryptoPP::MD5’ has not been declared
byte digest[ CryptoPP::MD5::DIGESTSIZE ];
^
cpp-md5sum.cpp:15:27: error: ‘digest’ was not declared in this scope
hash.CalculateDigest( digest, (byte*) message.c_str(),
message.length() );
On Tuesday, April 5, 2016 at 9:04:10 PM UTC-7, Jeffrey Walton wrote:
>
> Hi Leigh,
>
> On Tuesday, March 22, 2016 at 2:39:57 AM UTC-4, Leighb2282 wrote:
>>
>> Hey Folks, Apologies if this has already been answered a lot of times but
>> I'm a CryptoPP newbie and have not found anything usable so far that fits
>> the bill.
>>
>> I am looking to take an input string, calculate its md5 hash and output
>> the result, the code I have so far is below (and attached) and is taken and
>> slightly modified from an example on how to get a files MD5 which is where
>> I'm most likely tripping up.
>>
>> Could someone please explain why i'm going wrong here? is there an easier
>> (i.e. working) way to get the md5 of a string?
>>
>
> Sorry about the late reply here.
>
> Have a look at https://cryptopp.com/wiki/Hash_Functions.
>
> Jeff
>
>
--
--
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/d/optout.