-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Crypto: Digest hash with inputEncoding as 'binary' throws #3530
Comments
Seems like Latin1 encoding needs to be handled here. Lines 523 to 549 in 3aaec12
diff --git a/src/bun.js/node/types.zig b/src/bun.js/node/types.zig
index 96d04636..a8bf4fea 100644
--- a/src/bun.js/node/types.zig
+++ b/src/bun.js/node/types.zig
@@ -541,8 +541,12 @@ pub const Encoding = enum(u8) {
const result = JSC.ZigString.init(out).toValueGC(globalThis);
return result;
},
+ .latin1 => {
+ const result = JSC.ZigString.init(input).toValueGC(globalThis);
+ return result;
+ },
else => {
globalThis.throwInvalidArguments("Unexpected encoding", .{});
return JSC.JSValue.zero;
},
}
@@ -571,8 +575,12 @@ pub const Encoding = enum(u8) {
const result = JSC.ZigString.init(out).toValueGC(globalThis);
return result;
},
+ .latin1 => {
+ const result = JSC.ZigString.init(input).toValueGC(globalThis);
+ return result;
+ },
else => {
globalThis.throwInvalidArguments("Unexpected encoding", .{});
return JSC.JSValue.zero;
},
}
|
Merged
Jarred-Sumner
added a commit
that referenced
this issue
Jul 10, 2023
Jarred-Sumner
added a commit
that referenced
this issue
Jul 13, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What version of Bun is running?
0.6.13 and 0.6.14
What platform is your computer?
Darwin 20.6.0 arm64 arm
What steps can reproduce the bug?
What is the expected behavior?
I should see the hash value encoded in binary.
What do you see instead?
Additional information
A similar issue was fixed but it was the case of
hash.update(msg, 'binary')
. This is happening when we're using.digest
(hash.digest('binary')
).The text was updated successfully, but these errors were encountered: