0

I am unable to figure out why the following two files are yielding different hashes (SHA1, CRC32, SHA384, whatever):

https://cdn.jsdelivr.net/npm/[email protected]/dist/jsonify-error.js

https://cdn.jsdelivr.net/npm/[email protected]/dist/jsonify-error.js

I tried several diff utilities so far but all of them claim the files are identical.

I downloaded both files and checked them with Sublime Text 3 and Visual Studio Code, both seem to be UTF-8, CRLF, but as soon as I open the first and hit Ctrl+S on it (without changing anything!) its hash changes to be the same as the second one.

What is happening here?

EDIT to clarify: I want to know what is different between the files. I know it is something with whitespace characters or line endings, but what? Which line? Where? Which character?

0

2 Answers 2

2

Line 1 in v1.2.1 ended as linux EOL, while ver 1.2.2 on the same line has windows line ending.
(Linux use as line separator 0x0A character, while windows using 0x0D,0x0A)

The same with lines: 3, 4, 59, 60 and 61.

Tool used to spot the issue is WinMerge.

0
1

Look in a hex editor: one file uses 0x0a (LF) to mark end of line, the other uses 0x0d0a (CR/LF). Use a tool such as Notepad++ to change files to the same newline convention, if you must.

Hex view of 2 files

2
  • What caught me off guard is that it's not all lines, but only a few of them, right? Only lines 1, 3, 4, 59, 60 and 61, for some odd reason (as shown in the other answer)
    – Pedro A
    Commented Aug 15, 2018 at 23:49
  • Perhaps files were moved from one OS to another and edited there? Commented Aug 16, 2018 at 0:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .