From 47c8491114d67161dd4acbfdf9ff192a7740a9c0 Mon Sep 17 00:00:00 2001 From: Brendan Byrd Date: Wed, 28 Nov 2018 22:39:29 -0500 Subject: [PATCH] Add support for base64 in rom.gethash --- src/lua-engine.cpp | 9 ++++++--- web/help/LuaFunctionsList.html | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/lua-engine.cpp b/src/lua-engine.cpp index 2026a437..744baa85 100644 --- a/src/lua-engine.cpp +++ b/src/lua-engine.cpp @@ -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; } diff --git a/web/help/LuaFunctionsList.html b/web/help/LuaFunctionsList.html index 5854e01a..3b8ebd55 100644 --- a/web/help/LuaFunctionsList.html +++ b/web/help/LuaFunctionsList.html @@ -224,7 +224,7 @@


rom.gethash(string type)


-

Get a hash of the ROM loaded, for verification. The only currently supported type is "md5".

+

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.


rom.readbyte(int address)

rom.readbyteunsigned(int address)