-
Notifications
You must be signed in to change notification settings - Fork 30k
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
Buffer.from(string, 'hex') needs a documentation update (was: Buffer.from(x, hex
).toString(hex
) does not return x for certain values of x)
#29786
Comments
All of your problematic examples have an odd number of characters. People file issues like this from time to time which suggests that a doc update is in order. Here's a previous example: #24491 |
hex
).toString(hex
) does not return x for certain values of xhex
).toString(hex
) does not return x for certain values of x)
Added |
@Trott I would like to work on this issue |
Go for it. |
fixes: nodejs#29786 refs: nodejs#29792 refs: nodejs#24491
Then it is very inconsistent: |
I suppose that suggests another possibility: add a leading 0 if needed so that |
Run these in the REPL:
I expected
.toString('hex')
to be the inverse operation ofBuffer.from(x, 'hex')
, but it doesn't seem to be the case. Why not?I was able to catch this error using
fast-check
and it found a few other strings that behave this way:The text was updated successfully, but these errors were encountered: