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

Provide sha256 as a primitive in Starlark #275

Open
shs96c opened this issue Apr 17, 2024 · 1 comment
Open

Provide sha256 as a primitive in Starlark #275

shs96c opened this issue Apr 17, 2024 · 1 comment

Comments

@shs96c
Copy link

shs96c commented Apr 17, 2024

Many uses of Starlark require hashes in order to verify inputs are correct (examples include things like the sha56 attribute of http_archive in Bazel). It would be very beneficial if Starlark offered a function to allow hashes to be calculated.

The simplest way to do this would be a sha256 primitive, but an alternative design may be to modify hash to include an optional algorithm parameter, allowing for a path towards extending the hashing in a stable way (eg. to offer Blake3 or similar support)

@stepancheg
Copy link
Contributor

buck2 has sha256 builtin. Bazel may have it too, and I think this is actually a feature request for Bazel, not for starlark spec?

This function may be not generic enough to be included in the language specification. For example, in buck2 sha256 returns hex string. But maybe someone else needs digest as bytes? Or someone may want to have stateful sha256 algorithm to update it with chunks. Or someone would want sha1 and sha3? Starlark standard library is very small, and this would be quite large addition.

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

2 participants