37 lines
809 B
C++
37 lines
809 B
C++
#ifndef B6E698FD_68E6_4CB8_9BBA_BFE96C7501B0
|
|
#define B6E698FD_68E6_4CB8_9BBA_BFE96C7501B0
|
|
#include <Poco/DigestStream.h>
|
|
#include <Poco/MD5Engine.h>
|
|
#include <Poco/UUID.h>
|
|
#include <Poco/UUIDGenerator.h>
|
|
#include <iostream>
|
|
|
|
namespace Util
|
|
{
|
|
class Md5Util
|
|
{
|
|
public:
|
|
static std::string md5(const std::string& data)
|
|
{
|
|
Poco::MD5Engine md5Engine;
|
|
|
|
Poco::DigestOutputStream dos(md5Engine);
|
|
dos << data;
|
|
dos.close();
|
|
|
|
const Poco::DigestEngine::Digest& digest = md5Engine.digest();
|
|
|
|
return Poco::DigestEngine::digestToHex(digest);
|
|
}
|
|
|
|
static std::string uuid()
|
|
{
|
|
Poco::UUIDGenerator& generator = Poco::UUIDGenerator::defaultGenerator();
|
|
|
|
Poco::UUID uuid = generator.createRandom();
|
|
|
|
return uuid.toString();
|
|
}
|
|
};
|
|
}
|
|
#endif
|