1

这是我使用的命令(在 Windows 框中):

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

它按预期创建 xml,但 md5 校验和似乎是错误的。如果我运行以下命令:

$ FCIV -md5 file.txt

我得到了我认为正确的校验和(与 linux box 给我的匹配)。无论哪种方式,我都不明白为什么输出到 config.xml 会有不同的文件校验和。

如果我将第二个命令输出到 xml,则 md5 校验和似乎是错误的(与第一个命令相同)。

是否有我需要但找不到的参数(我用谷歌搜索过,手册页..)?还是我误解了这里的工作原理?一如既往,感谢您的帮助!:)

4

2 回答 2

2

我最近不得不自己以这种方式进行一些转换,并使用 python (2.7) 来完成它。下面的代码以防它帮助任何人:

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))

例子:

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

>>> xmlToHash('jKXXRHv+Jc6fKbtw4fyvWQ==')
'8ca5d7447bfe25ce9f29bb70e1fcaf59'
于 2017-09-27T18:27:03.403 回答
1

所以问题是FCIV在保存到xml时以Base 64编码了哈希。这是回答我问题的链接:http: //hansbobby.logdown.com/posts/200764-decode-base64-binary-sha1-hash

基本使用命令:echo 'FCC9sNSHaSfhqpYS3JwEgKzeL3I=' | openssl enc -base64 -d | xxd-p。必须 yum 安装 vim-common。

以下链接也很有帮助,解释了问题: https ://social.technet.microsoft.com/Forums/windowsserver/en-US/a828e6a5-c142-4b9a-8936-260a9da4a9c4/sha1-hashes-and-base64-encoding -怪异

于 2014-12-16T06:29:35.373 回答