Windows FCIV md5chucksum utility doesn't have the right md5sum when export to xml

1.2k Views Asked by At

Here is the command I use (on a windows box):

$ FCIV -md5 C:\Files -xml C:\data\config.xml -r

It creates the xml as expected but the md5 checksums seem to be wrong. If I run the following command:

$ FCIV -md5 file.txt

I get what I believe to be the correct checksum (matches what linux box gives me). Either way I don't understand why outputting to config.xml would have a different checksum of the file.

If I output the second command to xml the md5 checksum seems to be wrong (same sum as the first command).

Is there a parameter I need that I can't find (I've googled, man page..)? Or am I misunderstanding how something works here? As always, appreciate the help! :)

2

There are 2 best solutions below

0
On BEST ANSWER

So the problem was that FCIV encoded the hash in Base 64 when saving to xml. Here is the link that answered my question: http://hansbobby.logdown.com/posts/200764-decode-base64-binary-sha1-hash

Basically used the command: echo 'FCC9sNSHaSfhqpYS3JwEgKzeL3I=' | openssl enc -base64 -d | xxd -p. Had to yum install vim-common.

The following link was also helpful, explaining the problem: https://social.technet.microsoft.com/Forums/windowsserver/en-US/a828e6a5-c142-4b9a-8936-260a9da4a9c4/sha1-hashes-and-base64-encoding-wierdness

0
On

I recently had to do some conversions in this manner myself, and used python (2.7) to get it done. Code below in case it helps anyone:

import binascii

#convert checksum printed in fciv command line output to format stored in xml file
def hashToXml(checksum):
    #the trailing index notation is to trim the trailing /n added by b2a_base64
    return binascii.b2a_base64(binascii.unhexlify(checksum))[:-1]

#convert format stored in xml to checksum printed in fciv command line output
def xmlToHash(xmlstring):
    return binascii.hexlify(binascii.a2b_base64(xmlstring))

Example:

>>> hashToXml('8ca5d7447bfe25ce9f29bb70e1fcaf59')
'jKXXRHv+Jc6fKbtw4fyvWQ=='

>>> xmlToHash('jKXXRHv+Jc6fKbtw4fyvWQ==')
'8ca5d7447bfe25ce9f29bb70e1fcaf59'