这应该是可能的。MANIFEST.MF文件包含各个类文件的Base64编码的SHA-1。
从您的文档中:
In the manifest file, the SHA digest value for each source file is the
digest (hash) of the binary data in the source file. In the .SF file,
on the other hand, the digest value for a given source file is the
hash of the three lines in the manifest file for the source file.
因此,遍历所有类文件,计算SHA-1,将其格式显示在MANIFEST.MF中,然后对其进行哈希处理并按其格式显示在SF文件中。
计算不涉及任何键。
示例:考虑“ jce1_2_2.jar”(或任何您已经正确签名的)。这包含
表格的MANIFEST.MF条目
Name: javax/crypto/KeyAgreement.class
SHA1-Digest: c2p0JimzpV0dG+NChGLl5cI7MuY=
它们是“ KeyAgreement.class”的Base64(SHA1-1)(路径无关)。注意第三个空行。行尾为CRLF(Windows)。
Meta-INF / 4JCEJARS.SF条目
Name: javax/crypto/KeyAgreement.class
SHA1-Digest: whGBXE+AvYO6wAoVCdnocOPIrsE=
这不是文件的哈希值,而是上面三行的哈希值。