Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug with SHA256 checksums #4

Open
nightwatchcyber opened this issue Apr 18, 2021 · 1 comment
Open

Bug with SHA256 checksums #4

nightwatchcyber opened this issue Apr 18, 2021 · 1 comment

Comments

@nightwatchcyber
Copy link

On MacOS, "sha256sum" generates a file with two spaces between the hash and the filename. This causes filehash to fail verification while sha256sum works fine. This is due to the fact that text files are marked with a " " / space, and binary files with "*":
https://linux.die.net/man/1/sha256sum

To replicate, run the following commands:

cd testdata/
sha256sum *.zip >mac_test.txt
sha256sum --check mac_test.txt
chkfilehash -c mac_test.txt

Output from sha256sum:

lorem_ipsum.zip: OK

Output from fileshash:

Traceback (most recent call last):
  File "/usr/local/bin/chkfilehash", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.9/site-packages/filehash/filehash_cli.py", line 100, in main
    process_checksum_file(args.checksums, hasher)
  File "/usr/local/lib/python3.9/site-packages/filehash/filehash_cli.py", line 82, in process_checksum_file
    results = hasher.verify_checksums(checksum_filename)
  File "/usr/local/lib/python3.9/site-packages/filehash/filehash.py", line 268, in verify_checksums
    actual_hash = self.hash_file(filename)
  File "/usr/local/lib/python3.9/site-packages/filehash/filehash.py", line 176, in hash_file
    with open(filename, mode="rb", buffering=0) as fp:
FileNotFoundError: [Errno 2] No such file or directory: ' lorem_ipsum.zip'
```
@nightwatchcyber
Copy link
Author

I added a pull request with a fix

cyanea-bt added a commit to cyanea-bt/filehash that referenced this issue Jun 5, 2024
Bugfix for text file issue (leonidessaguisagjr#4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant