0

When I tried to encode YouTube url again to base64, the value after = didn't changed except first two letters. Is that already in base64? Url Converted: http://www.youtube.com/watch?v=CvUN8qg9lsk

Output(b64): http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DCvUN8qg9lsk

Why they are same?

5
  • 1
    Please look closer. The first 2 letters did not change either. It only changed = to %3D, and ? to %3F
    – LPChip
    Apr 3, 2018 at 11:01
  • Which means the url is already encoded in b64? But I can't decode that to normal form; why?
    – Ben Druno
    Apr 3, 2018 at 11:30
  • No, it means that base64 only encodes the special chars: :/?= present in the url, not tha alphanumeric chars and the . It seems the base64 encoder is actually an url encoder. Given that you haven't actually mentioned what kind of encoding you use and where you use it, answering this question other htan that I did is going to be hard to near impossible.
    – LPChip
    Apr 3, 2018 at 12:43
  • Yeah, it's url encoding. Base64 includes other encoding too , uft,Iso, all comes under base64 encoding,right?
    – Ben Druno
    Apr 3, 2018 at 15:04
  • For url encoding, it works exactly as designed. making sure the new string works by only encoding what is strictly necessary.
    – LPChip
    Apr 3, 2018 at 15:38

1 Answer 1

0

When I tried to encode a YouTube URL to base64 again, the value after the = sign didn't change, except for the first two letters. Is the last portion already in base64?

Minus the = sign being translated into %3D, yes, CvUN8qg9lsk is already encoded in Base64.

Why are they the same?

As @LPChip points out, the function you are using is a URL encoder which is translating only special characters in the URL (:, /, ?, + and =) into their hexadecimal equivalents (not normal letters).

Base64 includes other encoding too, right?

While URL encoding is considered a form of Base64 encoding, it is worthwhile to note that that term is potentially overloaded. Per Wikipedia (emphasis added):

"Base64 is a group of similar binary-to-text encoding schemes that represent binary data in an ASCII string format by translating it into a radix-64 representation."

In short, the base64 function you are using isn't meant to encode/decode CvUN8qg9lsk.

As a small side note, if you add a = (padding) and try to translate e.g. CvUN8qg9lsk= with a "normal" Base64 encoder/decoder, this may work. That said, it's unlikely you'll get anything worthwhile (i.e. meaningful to humans). It's very likely the values YouTube uses to get its IDs are the product of a very specific algorithm that likely has no relation to anything outside Google/YouTube.

5
  • That's clear. But I heard that b64 is made because of the network medium is not able to transfer 2^7 bits, so the binary actually got split into 6 bits with 4 sets; 2^6=64 . So it could transfer through our network. Is this a real fact?
    – Ben Druno
    Apr 7, 2018 at 12:12
  • Yes, sort of. Years ago, 2^7 bits per character (normal ASCII, 128 total values) became a standard for transferring data, while most computers operate with 2^8 bits (256 values). Thus there are values outside the ability of 128 bits to represent. That is (primarily) why the data is split, though Base64 also helps preserve line encoding between different operating systems and can have other advantages. Apr 7, 2018 at 12:56
  • Sir,when I saw the source code of gmail,I could see that everything in gmail website especially , drawer icon, and every single icons used to build the gmail website is encoded in b64. My question is why they encode icons and even logos in b64.? They have their own hosting server and why can't they just upload those icons there and apply those links while building the site? I hope they use b64 encoding for viewing the image without any problems. But why can't they upload the give that link?
    – Ben Druno
    Apr 8, 2018 at 6:53
  • Inline images (potentially) increase page speed (at least if the pictures are small, like icons). They prevent any separate, external request for an image (including from Google services), which can cause lag. That said, as side benefits for Google, I imagine it might increase reliability to some degree and reduce the size of the infrastructure they have to maintain. But that's a guess. Apr 8, 2018 at 8:52
  • It also reduce unprivileged access for some instance.
    – Ben Druno
    Apr 8, 2018 at 9:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .