You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.**
We want to hash error codes and custom values in the request/response for logging purposes. SHA256 is also used with Persisted Queries and caching so being able to generate the same values in Rhai could help with custom scripting
Base64 encoding doesn't help because anyone who has access to the encoded messages can easily decode them vs sha256 hashing which is one way
Describe the solution you'd like**
Expose new global functions in rhai, similar to base64::*, but for sha256
let text = "alice and bob";
let hash = sha256::digest(text);
print(hash) # 629f44ee052437b149370d37b9810e19a1df618712ccae63593d37c9b96e3237
Describe alternatives you've considered**
We could use a coprocessor to solve this today
Additional context**
This was brought up in a larger issue as one step to support encryption in Rhai in #2025 but that issue was closed because we added native Sigv4 support. This issue was also opened just for the sha256 function, but it was closed as a duplicate of the larger crypto issue: #2112
Outside of crypto support it would be helpful to have a sha256 hashing function available so we don't have to use a coprocessor for small request/response manipulation
The text was updated successfully, but these errors were encountered:
This adds a new `sha256::digest` function to Rhai to enable hash values.
Fixes#4939
<!-- start metadata -->
---
**Checklist**
Complete the checklist (and note appropriate exceptions) before the PR
is marked ready-for-review.
- [x] Changes are compatible[^1]
- [x] Documentation[^2] completed
- [ ] Performance impact assessed and acceptable
- Tests added and passing[^3]
- [x] Unit Tests
- [ ] Integration Tests
- [ ] Manual Tests
Is your feature request related to a problem? Please describe.**
We want to hash error codes and custom values in the request/response for logging purposes. SHA256 is also used with Persisted Queries and caching so being able to generate the same values in Rhai could help with custom scripting
Base64 encoding doesn't help because anyone who has access to the encoded messages can easily decode them vs sha256 hashing which is one way
Describe the solution you'd like**
Expose new global functions in rhai, similar to
base64::*
, but for sha256Describe alternatives you've considered**
We could use a coprocessor to solve this today
Additional context**
This was brought up in a larger issue as one step to support encryption in Rhai in #2025 but that issue was closed because we added native Sigv4 support. This issue was also opened just for the sha256 function, but it was closed as a duplicate of the larger crypto issue: #2112
Outside of crypto support it would be helpful to have a sha256 hashing function available so we don't have to use a coprocessor for small request/response manipulation
The text was updated successfully, but these errors were encountered: