Add support for base64 in rom.gethash

This commit is contained in:
Brendan Byrd 2018-11-28 22:39:29 -05:00
parent 319293e20b
commit 47c8491114
2 changed files with 7 additions and 4 deletions

View File

@ -1330,9 +1330,12 @@ static int rom_getfilename(lua_State *L) {
static int rom_gethash(lua_State *L) {
const char *type = luaL_checkstring(L, 1);
if(!type) lua_pushstring(L, "");
else if(!stricmp(type,"md5")) lua_pushstring(L, md5_asciistr(GameInfo->MD5));
else lua_pushstring(L, "");
MD5DATA md5hash = GameInfo->MD5;
if (!type) lua_pushstring(L, "");
else if (!stricmp(type, "md5")) lua_pushstring(L, md5_asciistr(md5hash));
else if (!stricmp(type, "base64")) lua_pushstring(L, BytesToString(md5hash.data, MD5DATA::size).c_str());
else lua_pushstring(L, "");
return 1;
}

View File

@ -224,7 +224,7 @@
<p><span class="rvts37"><br/></span></p>
<p><span class="rvts63">rom.gethash(string type)</span></p>
<p><span class="rvts37"><br/></span></p>
<p><span class="rvts37">Get a hash of the ROM loaded, for verification. The only currently supported type is "md5".</span></p>
<p><span class="rvts37">Get a hash of the ROM loaded, for verification. If type is "md5", returns a hex string of the MD5 hash. If type is "base64", returns a base64 string of the MD5 hash, just like the movie romChecksum value.</span></p>
<p><span class="rvts37"><br/></span></p>
<p><span class="rvts63">rom.readbyte(int address)</span></p>
<p><span class="rvts63">rom.readbyteunsigned(int address)</span></p>