mirror of
https://github.com/Kiritow/MiniEngine.git
synced 2024-03-22 13:11:22 +08:00
38 lines
730 B
C++
38 lines
730 B
C++
|
#include "MiniEngine_Test.h"
|
||
|
#include <SDL2/SDL_test.h>
|
||
|
#include <cstring>
|
||
|
|
||
|
namespace MiniEngine
|
||
|
{
|
||
|
|
||
|
namespace Test
|
||
|
{
|
||
|
|
||
|
void GetMD5Raw(unsigned char* buffer,unsigned int bufferLen,unsigned char* outbuff)
|
||
|
{
|
||
|
SDLTest_Md5Context ct;
|
||
|
SDLTest_Md5Init(&ct);
|
||
|
SDLTest_Md5Update(&ct,buffer,bufferLen);
|
||
|
SDLTest_Md5Final(&ct);
|
||
|
memcpy(outbuff,ct.digest,16);
|
||
|
}
|
||
|
|
||
|
std::string GetMD5(unsigned char* buffer,unsigned int bufferLen)
|
||
|
{
|
||
|
unsigned char buff[16];
|
||
|
char tmp[8];
|
||
|
GetMD5Raw(buffer,bufferLen,buff);
|
||
|
std::string str;
|
||
|
for(int i=0;i<16;i++)
|
||
|
{
|
||
|
sprintf(tmp,"%02x",buff[i]);
|
||
|
str.append(tmp);
|
||
|
}
|
||
|
return str;
|
||
|
}
|
||
|
|
||
|
|
||
|
}/// End of namespace MiniEngine::Test
|
||
|
|
||
|
}/// End of namespace MiniEngine
|