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

Leading zeroes are dropped when both the input alphabet and string start with a 0 #4

Closed
Spotlightsrule opened this issue Jul 14, 2020 · 2 comments

Comments

@Spotlightsrule
Copy link

Spotlightsrule commented Jul 14, 2020

I am using the base converter to convert hexadecimal strings into alphanumeric ones, but if the hex string starts with a zero, the leading zero gets dropped during the conversion process resulting in the output string being non-reversible due to the same output string generating both with and without the leading zero. In addition, this only seems to occur when running the code in NodeJS and not in the web browser where the zero magically appears in the reversal process despite the two different strings resulting in the same output. My parameters to re-produce the issue are as follows:
Input alphabet: 0123456789abcdef
Input string: 090e5c14c2237ecbc906879d50ae1b12
Output alphabet: 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz

The resulting output string both with and without the leading zero in the input string: H5UaOom3uXr7KMPbuIFHe

UPDATE: I just tried this with a different input alphabet and string, and I was able to trigger the bug there too. This seems to occur whenever both the input alphabet and string begin with 0, so for example the following parameters will also trigger it:
Input alphabet: 01234abc
Input string: 0143ac4cb213411abcbbac
Output alphabet: 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz

@Spotlightsrule Spotlightsrule changed the title Leading zeroes are dropped in hexadecimal base conversions Leading zeroes are dropped when both the input alphabet and string start with a 0 Jul 14, 2020
@zamicol
Copy link
Owner

zamicol commented Jul 15, 2020

This is a duplicate of #1. Your leading zero is a padding character.

It's a problem of defining behavior.

Do we just want padding characters transferred over 1:1? Include a checkbox that says "copy padding characters"?

Just FYI, you can share links using the "Share" button:

https://convert.zamicol.com/?in=090e5c14c2237ecbc906879d50ae1b12&inAlpha=0123456789abcdef&outAlpha=0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz

@zamicol zamicol closed this as completed Jul 15, 2020
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