zayamatias
Posts: 2
Joined: Mon Aug 13, 2018 2:47 pm

MAME SHA1 Calculation

Tue Aug 14, 2018 8:00 am

Hi Everybody, I'm new to this forum so excuse me if I ask this in the inappropriate section.

Lately I started developing on the NeoGeo platform (just for fun), and I use MAME to quickly test the developments. In order to have a more "clean" experience, I've developed a tool in python in order to add/modify my "code" into the hash file neogeo.xml . Until there nothing extraordinary (you can check it here https://github.com/zayamatias/neogeo if you wish).

In the "rom" section of each software/part/dataarea you have one attribute called SHA1, which actually holds the hash for that particular file.

My tool also calculates the SHA1 of the file (based on code found on the net) and puts its value into that attribute so you hopefully do not get that "this game might not work properly" warning.

What is strange though, is that the calculation of my tools for files compiled by the assembler or even sprite files are not the same as MAME's calculations, and I have discrepancies as a result.

I checked online "hash tools" and they all give me the same results as my tool, but not the same as MAME. I checked with "existing" roms, and in this case, both my tool and mame calculate correctly.

Is there anything I'm missing on how MAME is calculating the SHA1 hash?

Thanks a lot !!

User avatar
Robert
Posts: 59
Joined: Thu Nov 06, 2014 12:44 pm
Location: Land of Oz
Contact: Website

Re: MAME SHA1 Calculation

Sun Aug 19, 2018 10:52 am

When we add roms to the source, we use an in-house utility written in python to calculate the crc32 and sha1, and it produces formatted output which we paste into the game's rom definition.

There appears to be a "sha1" library in python; the utility simply asks this library to calculate the sha1.
We've never had a problem with it.

Since you're also using python perhaps you could investigate this library.

Code: Select all

import zipfile import os.path import sha ...... # Calculate SHA-1 of the file sha1 = sha.new(z.read(fileName)).hexdigest()

zayamatias
Posts: 2
Joined: Mon Aug 13, 2018 2:47 pm

Re: MAME SHA1 Calculation

Mon Aug 20, 2018 7:30 am

Hi!!

Thanks a lot for the reply, that actually worked... wonder why the other python library had these discrepancies. Again, thanks!

Return to “MAME Discussion”

Who is online

Users browsing this forum: No registered users and 2 guests