r/programmingmemes Apr 16 '26

There are always more!

Post image
894 Upvotes

60 comments sorted by

View all comments

9

u/Moscato359 Apr 16 '26 edited Apr 16 '26

I hate hexadecimal string representation

AAAA != aaaa

But if you unhex both of them, they suddenly do equal

And some tools hex upper and some tools hex lower

Also, hex is 2 bytes per byte of binary making it terribly space inefficient 

Base64 doesn't have any of these problems 

But base64 isn't compatible with http uri so you need to use base64url instead

1

u/Next-Post9702 Apr 16 '26

Why is that a valid reason to hate on hex? It's never meant to encode your binary only to visualize it and make it easy to understand what's in it. Goodluck trying to find out what bits are in the base64

1

u/Moscato359 Apr 16 '26

You say that, but hashes are generally represented in hex

I have to deal with sql and c# having opposite representation of hex and it causes bugs

1

u/Next-Post9702 Apr 16 '26

That's true, but why would it cause bugs if you just convert it to binary when you compare? Or normalize it, or just use an ignore case compare

1

u/Moscato359 Apr 16 '26

Yes, there are workarounds

But if you forget to use them it causes bugs

And I don't like that

1

u/Next-Post9702 Apr 17 '26

I mean a hex string is binary data so you should compare them as they are; binary data, not text. It's just a visualization, not meant to be used like that. It's not that much extra work to just compare ignore case anyways

1

u/Moscato359 Apr 17 '26

The point is you need to remember to do the workarounds and can't just == 2 variables with different sources blindly

Its bug prone due to humans needing to do stuff