| ▲ | netsharc 7 days ago |
| Good knowledge, now explain why it's like that. {" is ASCII 01111011, 00100010 Base64 takes 3 bytes x 8 bits = 24 bits, groups that 24 bit-sequence into four parts of 6 bits each, and then converts each to a number between 0-63. If there aren't enough bits (we only have 2 bytes = 16 bits, we need 18 bits), pad them with 0. Of course in reality the last 2 bits would be taken from the 3rd character of the JSON string, which is variable. The first 6 bits are 011110, which in decimal is 30. The second 6 bits are 110010, which in decimal is 50. The last 4 bits are 0010. Pad it with 00 and you get 001000, which is 8. Using an encoding table (https://base64.guru/learn/base64-characters), 30 is e, 50 is y and 8 is I. There's your "ey". Funny how CS people are so incurious now, this blog post touches the surface but didn't get into the explanation. |
|
| ▲ | appreciatorBus 7 days ago | parent | next [-] |
| That’s really a leap about the writer’s interest. They could just as easily have felt the underlying reason was so obvious it wasn’t worth mentioning. I know how base64 encoding works but had never noticed the pattern the author pointed out. As soon as read it, I ubderstood why. It didn’t occur to me that the author should have explained it at a deeper level. |
| |
| ▲ | tharkun__ 7 days ago | parent [-] | | Is it? In the first paragraph the author clearly shows his ignorance of base64. When told that it "looks like base64 encoded JSON" he was incredulous but gave it a go, and it worked!!
Even if you don't notice the ey specifically the string itself just screams base64 encoding, regardless of what's actually inside. | | |
| ▲ | appreciatorBus 7 days ago | parent | next [-] | | TBC I was addressing the parents suggestion that the writer was incurious. One blog post is hardly enough to just someone as ignorant but after quick look at the author's writing/coding/job history, I doubt he is that either. I think it's fantastic that you can look at a string and feel it's base64 essence come through without a decoder. Thinking about it for a minute, I suspect I could train myself to do the same. If someone who already knew how to do it well wrote a how-to, I bet it would hit the front page and inspire many people, just like this article did. I just don't get the urge to dump on the original author for sharing a new-to-him insight. | |
| ▲ | creatonez 7 days ago | parent | prev [-] | | They were probably expecting base64 encoded binary data. Base64-encoded-binary-inside-Base64-encoded-JSON-inside-JSON is a really strange construction if you haven't encountered it before, because of how much space it's wasting playing a game of Russian nesting dolls. | | |
| ▲ | fc417fc802 7 days ago | parent [-] | | Just add a layer of compression periodically to reclaim the wasted space and it will all work out. | | |
| ▲ | throwaway4496 6 days ago | parent [-] | | If you have a compression that works on encrypted data, you can avoid wasting your time on the "encryption". | | |
| ▲ | fc417fc802 6 days ago | parent [-] | | Base64 isn't encryption. The overhead added follows an extremely predictable pattern. That said I've no idea what the performance of common compression algorithms might be in such a use case. The comment was entirely tongue in cheek. | | |
| ▲ | throwaway4496 6 days ago | parent [-] | | I apologise for my mistake. Either the comment got edited or I misread encryption somewhere in there. |
|
|
|
|
|
|
|
| ▲ | syncsynchalt 7 days ago | parent | prev | next [-] |
| I think the audience already understands why it works, it's more the knowing there's a relatively small set of mnemonics for these things that's interesting. "eyJ" for JSON, "LS0" for dashes (PEM encoding), "MII" for the DER payload inside a PEM, and so on. I've been doing this a long time but until today the only one I'd noticed was "MII". |
| |
| ▲ | ruszki 7 days ago | parent [-] | | The audience yes, but the author clearly seems to not understand it when they wrote this the first time. > I did a few tests in my terminal, and he was right! He clearly had no clue how base64 worked. You don’t need a test, if you know it. > As pointed out by gnabgib and athorax on Hacker News, this actually detects the leading dashes of the PEM format They needed help for this. I’m not sure that they opened Wikipedia at last to understand how base64 works even now. The whole article has an “it’s magic!” vibe. |
|
|
| ▲ | perching_aix 7 days ago | parent | prev | next [-] |
| I'd be very hesitant to consider this as some runaway symbol of "CS people being incurious now" over the author simply not being this deeply invested in this at the time of writing in the context of their discovery, especially since it almost certainly doesn't actually matter for them beyond the pattern existing, if even that does. |
| |
| ▲ | netsharc 7 days ago | parent [-] | | > it almost certainly doesn't actually matter for them beyond the pattern existing, if even that does. https://web.cs.ucdavis.edu/~rogaway/classes/188/materials/th... | | |
| ▲ | perching_aix 7 days ago | parent | next [-] | | And there goes my limit of curiosity now regarding this. I'm interested in what you have to say, but not 25 page mini-novel PDF from someone else interested. I'm glad you enjoyed that piece, but I have no interest in reading it, nor do I think it's reasonable for you to expect me to be interested. Much like with the author and the specifics of this encoding. | | |
| ▲ | netsharc 7 days ago | parent [-] | | [flagged] | | |
| ▲ | perching_aix 7 days ago | parent [-] | | I guess I fully deserve this as some sort of karmic retribution, because I'm usually the person in the room who's frustrated about people poking things they don't fully understand, about folks continuing to spitball rather than looking a layer deeper, and the one who over-obsesses over details. It took me a very long time to accept that sometimes ignorance is not only acceptable, but optimal, and it continues to challenge me to this day. You mention "being hackerly". Imagine you were reverse engineering some gnarly 100 MB obfuscated x86 binary. Surely you can appreciate that especially if you have a specific goal, it is overwhelmingly preferable to guess, experiment, and poke than to kick off some heroic RE effort that will take tens of people years, just so that you can supposedly "fully understand" what's happening. Attention is precious - not everything is worth equal attention. And it is absolutely possible to correctly guess things from limited information, and is even essential to be able to. You find base64 encoding interesting enough that you were able to either recall detailed facts about its operation from memory here, or looked it up quickly to break it down. How is the author, or me, not doing so is any evidence for you we're: - ignorant about how base64 works and always have been - don't care about (CS) things at depth in general These are such immensely strong claims to make. Surely you can appreciate that some people just have different interests sometimes? That they might focus on different things? That they can learn things and then forget about them? That to some level everything is connected, so appealing to that is not exactly some grand revelation of missing a "key piece"? Few years, or I guess more than just a few years ago, in college, I met up with a former classmate from primary school. He was studying history and shared some great (historical) stories that I really enjoyed. But then another thought formulated in my mind: if I had to actively study this, rather than just catch a story or two, I'd definitely be dropping out. And that's when I realized that there can be value to things, they can be interesting, yet at the same time it's OK for me not to be interested by them or pursue them deeper. Just like how I think it is perfectly OK to be interested in this pattern, but not care for the underlying mapping mechanism, as it is essentially irrelevant. The fun was in the fact, not in the mechanism (in my view for the author anyways). |
|
| |
| ▲ | Telemakhos 7 days ago | parent | prev [-] | | Wow, that's an amazing story. I'd never read anything by E. M. Forster before, and I certainly wasn't expecting 1920s sci-fi like that. |
|
|
|
| ▲ | nxnsxnbx 7 days ago | parent | prev | next [-] |
| The author also doesn't explain what JSON is. Because it's obvious to the target audience. There's simply no explanation necessary |
|
| ▲ | positisop 7 days ago | parent | prev | next [-] |
| I think CS grads often skip the part of how something actually works and are happy with abstractions. |
|
| ▲ | throwaway4496 7 days ago | parent | prev [-] |
| CS post covid is in the worst state it has ever been, vibe coding and AI has enabled a category of grifters beyond the wet dreams of blockchain hacks. |