Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

53
Views
baseurl64 buffer decoding

Can someone explain this behavior?

Buffer.from('5d9RAjZ2GCob-86_Ql', 'base64url').toString('base64url')

// 5d9RAjZ2GCob-86_Qg

Please take a close look at the last character l - g

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Your string is 18 characters long, With 6 Bits encoded in each character it means the first 16 characters represent 96 bytes and the last two represent one byte plus 4 unused bits. Only the first two bits of the last character are significant here. g is 100000, l is 100101. As the last 4 characters are not used, g is just the first choice for the two bits 1 0.

So for any character in the range between g and v, you would get a g when you convert it back to Base64Url. See https://en.wikipedia.org/wiki/Base64#Base64_table_from_RFC_4648

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!