question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bug report: FromHex then MD5/SHA1 has wrong computation

See original GitHub issue

Summary

When using FromHex then MD5 computation recipe, sometimes, the hash is wrong. It seems that bytes >= 0x80 have a problem with the transformation.

Example

See the following example:

screen shot 2017-10-08 at 16 43 33

The correct hash for a single 0x80 byte should be:

>>> import hashlib
>>> hashlib.md5(bytes([0x80])).hexdigest()
'8d39dd7eef115ea6975446ef4082951f'

Possible solutions

It seems that at least another online tool is failing at this: https://cryptii.com/hexadecimal/md5 Note that the result for SHA1 is also wrong. However, the new version https://v4.cryptii.com/enigma outputs the correct result.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:10 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
nf404commented, Oct 8, 2017

This is because update accept message as utf-8 string. U need to use updateFromArray for binary data.

var hash = CryptoApi.hasher('md5'); hash.update('\x80'); hash.finalize().stringify('hex')
// result: "602a4f1ee0d3c4da4fe18df6708ba8e0"
var hash = CryptoApi.hasher('md5'); hash.updateFromArray([0x80]); hash.finalize().stringify('hex')
// result: "8d39dd7eef115ea6975446ef4082951f"
0reactions
n1474335commented, Oct 9, 2017

@slurdge Ah yes, I misunderstood. If the manual state update method is for strings then go ahead and leave it as a string. Make sure you run grunt test once you’ve made the changes in case some of the hashing tests break. They shouldn’t as I generated the expected hashes using Python and some other online sources, however those other sources might also be wrong in the same way.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Ten simple rules for reporting a bug - PLOS
Bugs, of course, are flaws in computer software—flaws that can make the software crash, become unresponsive, or produce incorrect output, or ...
Read more >
How to get the MD5 and SHA1 checksum for a file - IBM
The tool to use to compute the checksum is: sha1sum. ... If two files have the same MD5 checksum value, then there is...
Read more >
How to Report Bugs Effectively - PowerWorld
Anybody who has written software for public use will probably have received at least one bad bug report. Reports that say nothing ("It...
Read more >
Ten simple rules for reporting a bug - PMC - NCBI - NIH
Bugs, of course, are flaws in computer software—flaws that can make the software crash, become unresponsive, or produce incorrect output, or ...
Read more >
HEC-FDA Bug Report - Hydrologic Engineering Center
If you have encountered a problem, then please take the time to send us a bug report. USACE users: Please submit bug reports...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found