0

I am struggling with this topic as I get different results than I would expect.

When encoding the value '1455344' (as string not as integer) I get 'MTQ1NTM0NA=='.

When using the converter from this page: https://base64.guru/standards/base64url/encode

I get a slight different result 'MTQ1NTM0NA'.

What is wrong and what is correct? and what do I need to do to get the second results?

When encoding '799468', in both cases the result is 'Nzk5NDY4'

Any clarification would be very appreciated. Thanks Andreas

By mistake i had posted my question as answer instead of an additional question in the following topic: Base64 encoding in SQL Server 2005 T-SQL

  • The first answer befor the deletion of the post was: That is base64 padding (see en.wikipedia.org/wiki/Base64#Output_padding). Some implementations decide to keep the padding and some discard it. I'd recommend you post this as a StackOverflow question instead, though, not as an answer. Hopefully the comment reaches you before your answer post is removed. – Jacob – Andreas Ketelhut Jun 15 '20 at 05:48
  • As Jakob said, the `==` is just padding. Every base64 character represents 6 bits, so 4 of them encode 24 bit or 3 bytes. Therefore a base64 string should be divisible by 4 and if not it should be padded with 1 or 2 `=`. In the first case you need 2 padding chars, in the second case there's no need. – jps Jun 15 '20 at 07:44

0 Answers0