MCPcopy Create free account
hub / github.com/defold/defold / HashMD5

Function HashMD5

engine/script/src/script_hash.cpp:134–151  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

132 }
133
134 static int HashMD5(lua_State* L)
135 {
136 int top = lua_gettop(L);
137
138 size_t len;
139 const char* str = luaL_checklstring(L, 1, &len);
140
141 uint8_t d[16];
142 dmCrypt::HashMd5((const uint8_t*)str, len, d);
143
144 char md5[16 * 2 + 1]; // We need a terminal zero for snprintf
145 dmSnPrintf(md5, sizeof(md5), "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
146 d[0], d[1], d[2], d[3], d[4], d[5], d[6], d[7], d[8], d[9], d[10], d[11], d[12], d[13], d[14], d[15]);
147 lua_pushstring(L, md5);
148
149 assert(top + 1 == lua_gettop(L));
150 return 1;
151 }
152
153 static int CreateLuaHashUserdata(lua_State* L, dmhash_t hash)
154 {

Callers

nothing calls this directly

Calls 6

lua_gettopFunction · 0.85
luaL_checklstringFunction · 0.85
HashMd5Function · 0.85
dmSnPrintfFunction · 0.85
lua_pushstringFunction · 0.85
assertFunction · 0.50

Tested by

no test coverage detected