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

Polyfilling sha256 #1

Open
mentalisttraceur opened this issue Feb 27, 2024 · 1 comment
Open

Polyfilling sha256 #1

mentalisttraceur opened this issue Feb 27, 2024 · 1 comment

Comments

@mentalisttraceur
Copy link

mentalisttraceur commented Feb 27, 2024

You have a comment in the readme about being unable to make sha256 portable without relying on Python.

Well, there's at least partial progress to be made by using shasum as a fallback. For example:

if command -v sha256sum >/dev/null
then
    sha256sum ...
else
    shasum -a 256 ...
fi

I believe this will cover basically every modern practically usable system that has a /bin/sh.

In particular, to my knowledge/memory, this covers

  1. basically every Linux distro (sha256sum installed by default),
  2. Git Bash, BusyBox-w32, and the like on Windows, and
  3. MacOS (shasum installed by default).
@mentalisttraceur mentalisttraceur changed the title sha256sum == shasum -a 256 Polygolling sha256 Feb 27, 2024
@mentalisttraceur mentalisttraceur changed the title Polygolling sha256 Polyfilling sha256 Feb 27, 2024
@mentalisttraceur
Copy link
Author

If neither exists, yet another option which might be available in places Python isn't is the openssl CLI: openssl sha256, although that has a different output format than the already mentioned.

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