整理代码
This commit is contained in:
commit
c7b4e178ec
364 changed files with 59691 additions and 0 deletions
37
util/Md5Util.h
Normal file
37
util/Md5Util.h
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
#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
|
||||
Loading…
Add table
Add a link
Reference in a new issue