#include <iostream>
#define CRYPTOPP_DEFAULT_NO_DLL
#include <cryptopp/dll.h>
#ifdef CRYPTOPP_WIN32_AVAILABLE
#include <windows.h>
#endif
#include <cryptopp/md5.h>
USING_NAMESPACE(CryptoPP)
USING_NAMESPACE(std)
const int MAX_PHRASE_LENGTH=250;
int main(int argc, char *argv[]) {
CryptoPP::MD5 hash;
byte digest[ CryptoPP::MD5::DIGESTSIZE ];
std::string message = "Hello World!";
hash.CalculateDigest( digest, (const 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();
std::cout << "Input string: " << message << std::endl;
std::cout << "MD5: " << output << std::endl;
return 0;
}
#include <iostream>
#define CRYPTOPP_DEFAULT_NO_DLL
#include <cryptopp/dll.h>
#ifdef CRYPTOPP_WIN32_AVAILABLE
#include <windows.h>
#endif
#include <cryptopp/md5.h>
USING_NAMESPACE(CryptoPP)
USING_NAMESPACE(std)
const int MAX_PHRASE_LENGTH=250;
int main(int argc, char *argv[]) {
CryptoPP::MD5 hash;
byte digest[ CryptoPP::MD5::DIGESTSIZE ];
std::string message = "Hello World!";
hash.CalculateDigest( digest, (const 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();
std::cout << "Input string: " << message << std::endl;
std::cout << "MD5: " << output << std::endl;
return 0;
}
To copy to clipboard, switch view to plain text mode
#include <iostream>
#define CRYPTOPP_DEFAULT_NO_DLL
#include <cryptopp/dll.h>
#include <cryptopp/default.h>
#ifdef CRYPTOPP_WIN32_AVAILABLE
#include <windows.h>
#endif
USING_NAMESPACE(CryptoPP)
USING_NAMESPACE(std)
const int MAX_PHRASE_LENGTH=250;
void EncryptFile(const char *in,
const char *out,
const char *passPhrase);
void DecryptFile(const char *in,
const char *out,
const char *passPhrase);
int main(int argc, char *argv[])
{
try
{
char passPhrase[MAX_PHRASE_LENGTH];
cout << "Passphrase: ";
cin.getline(passPhrase, MAX_PHRASE_LENGTH);
EncryptFile(argv[1], argv[2], passPhrase);
DecryptFile(argv[2], argv[3], passPhrase);
}
catch(CryptoPP::Exception &e)
{
cout << "\nCryptoPP::Exception caught: "
<< e.what() << endl;
return -1;
}
catch(std::exception &e)
{
cout << "\nstd::exception caught: " << e.what() << endl;
return -2;
}
}
void EncryptFile(const char *in,
const char *out,
const char *passPhrase)
{
FileSource f(in, true, new DefaultEncryptorWithMAC(passPhrase,
new FileSink(out)));
}
void DecryptFile(const char *in,
const char *out,
const char *passPhrase)
{
FileSource f(in, true,
new DefaultDecryptorWithMAC(passPhrase, new FileSink(out)));
}
RandomPool & GlobalRNG()
{
static RandomPool randomPool;
return randomPool;
}
int (*AdhocTest)(int argc, char *argv[]) = NULL;
#include <iostream>
#define CRYPTOPP_DEFAULT_NO_DLL
#include <cryptopp/dll.h>
#include <cryptopp/default.h>
#ifdef CRYPTOPP_WIN32_AVAILABLE
#include <windows.h>
#endif
USING_NAMESPACE(CryptoPP)
USING_NAMESPACE(std)
const int MAX_PHRASE_LENGTH=250;
void EncryptFile(const char *in,
const char *out,
const char *passPhrase);
void DecryptFile(const char *in,
const char *out,
const char *passPhrase);
int main(int argc, char *argv[])
{
try
{
char passPhrase[MAX_PHRASE_LENGTH];
cout << "Passphrase: ";
cin.getline(passPhrase, MAX_PHRASE_LENGTH);
EncryptFile(argv[1], argv[2], passPhrase);
DecryptFile(argv[2], argv[3], passPhrase);
}
catch(CryptoPP::Exception &e)
{
cout << "\nCryptoPP::Exception caught: "
<< e.what() << endl;
return -1;
}
catch(std::exception &e)
{
cout << "\nstd::exception caught: " << e.what() << endl;
return -2;
}
}
void EncryptFile(const char *in,
const char *out,
const char *passPhrase)
{
FileSource f(in, true, new DefaultEncryptorWithMAC(passPhrase,
new FileSink(out)));
}
void DecryptFile(const char *in,
const char *out,
const char *passPhrase)
{
FileSource f(in, true,
new DefaultDecryptorWithMAC(passPhrase, new FileSink(out)));
}
RandomPool & GlobalRNG()
{
static RandomPool randomPool;
return randomPool;
}
int (*AdhocTest)(int argc, char *argv[]) = NULL;
To copy to clipboard, switch view to plain text mode
Bookmarks