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?
I also included the result of trying to compile the code (using g++ (Ubuntu
4.8.4-2ubuntu1~14.04.1) 4.8.4)
Many thanks for your patience and time.
~Leigh
#include <iostream>
#define CRYPTOPP_ENABLE_NAMESPACE_WEAK 1
#include <crypto++/md5.h>
#include <crypto++/hex.h>
int main()
{
std::string input = "foobarbat";
std::string result;
CryptoPP::Weak::MD5 hash;
CryptoPP::StringSink(input,new
CryptoPP::HashFilter(hash,new CryptoPP::HexEncoder(new
CryptoPP::StringSink(result),false)));
std::cout << result << std::endl;
return 0;
}
$ g++ -std=c++11 -lcrypto++ rctk-devs/cpp-md5sum.cpp -o bins/cpp-md5sum
rctk-devs/cpp-md5sum.cpp: In function ‘int main()’:
rctk-devs/cpp-md5sum.cpp:15:42: error: no matching function for call to
‘CryptoPP::StringSinkTemplate<std::basic_string<char>
>::StringSinkTemplate(std::string&, CryptoPP::HashFilter*)’
CryptoPP::StringSink(result),false)));
^
rctk-devs/cpp-md5sum.cpp:15:42: note: candidates are:
In file included from /usr/include/crypto++/basecode.h:4:0,
from /usr/include/crypto++/hex.h:4,
from rctk-devs/cpp-md5sum.cpp:6:
/usr/include/crypto++/filters.h:591:2: note:
CryptoPP::StringSinkTemplate<T>::StringSinkTemplate(T&) [with T =
std::basic_string<char>]
StringSinkTemplate(T &output)
^
/usr/include/crypto++/filters.h:591:2: note: candidate expects 1
argument, 2 provided
/usr/include/crypto++/filters.h:585:7: note: constexpr
CryptoPP::StringSinkTemplate<std::basic_string<char>
>::StringSinkTemplate(const
CryptoPP::StringSinkTemplate<std::basic_string<char> >&)
class StringSinkTemplate : public Bufferless<Sink>
^
/usr/include/crypto++/filters.h:585:7: note: candidate expects 1
argument, 2 provided
/usr/include/crypto++/filters.h:585:7: note: constexpr
CryptoPP::StringSinkTemplate<std::basic_string<char>
>::StringSinkTemplate(CryptoPP::StringSinkTemplate<std::basic_string<char>
>&&)
/usr/include/crypto++/filters.h:585:7: note: candidate expects 1
argument, 2 provided
--
--
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.
#include <iostream>
#define CRYPTOPP_ENABLE_NAMESPACE_WEAK 1
#include <crypto++/md5.h>
#include <crypto++/hex.h>
int main()
{
std::string input = "foobarbat";
std::string result;
CryptoPP::Weak::MD5 hash;
CryptoPP::StringSink(input,new
CryptoPP::HashFilter(hash,new CryptoPP::HexEncoder(new
CryptoPP::StringSink(result),false)));
std::cout << result << std::endl;
return 0;
}