| 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 | { |
nothing calls this directly
no test coverage detected