How do you insert a hash into a file recursively?

The simplest case: you want to create a text file that says: "MD5 hash of this file is FOOBARHASH." How do you insert a hash knowing that the inline hash value and the file hash are interconnected?

for example, Cisco embeds hash values ​​in its IOS images, which can be verified as follows:

cisco # verify s72033-advipservicesk9_wan-mz.122-33.SXH7.bin

MD5 Embedded Hash: D2BB0668310392BAC803BE5A0BCD0C6A
Calculated Hash MD5: D2BB0668310392BAC803BE5A0BCD0C6A

Maybe I'm wrong, but trying to figure out how to do this, this is my mind.

I initially stated that ISO Ubuntu has a text file containing an MD5 hash of the entire ISO file. This was incorrect: in the second image, the md5sum.txt file contains hashes for individual files.

+4
source share
1 answer

Not. The hash value is calculated by placing "dummy" or an empty line where the signature should be, hashing this document, and then inserting the signature value into the text. To verify the signature of a document, you delete the signature, hash the document without a signature, and compare the result with the signature signature.

If you like this call, consider writing a program to create self-describing pangrams:

This pangram contains four, one, two, one, three, three, six, five, six, eleven, one j, one k, two ls, two ss, eighteen ns, fifteen os, two ps, one q, five rs, twenty seven ss, eighteen ts, two of us, seven vs, eight ws, two xs, three ys and one z.

Good luck

+6
source

Source: https://habr.com/ru/post/1309162/


All Articles