base64 encode/decode padding

base64 encode/decode padding
Photo by Tobias Pfeifer / Unsplash

You might found base64 string somehow looks like always ends with "=". In fact, "=" is a padding when the base64 string length is not times 4.

for example, "errong.win" string convert to base64 will be "ZXJyb25nLndpbg==". The last two "=" are called padding.

issue with command "echo xxx | base64"

in k8s, the opaque Secret is encoding the secret value with base64. But it is not safe, better to use SealedSecret.

Encrypt your Secret into a SealedSecret, which is safe to store - even inside a public repository.

One of my colleagues encountered a wired issue. She create a opaque secret for a spring data source password value(base64 string via command "echo springdatasourcepassword | base64"). Then convert this secret to a sealed secret.

The sealed secret revealed value looks exactly same as the plain password. But her app always faced login issue. The root cause is the padding. The command didn't appended padding for the encoded password base64 string.

strong recommend: use base64 decode/encode online tool

Base64 Decode and Encode - Online
Decode from Base64 format or encode into it with various advanced options. Our site has an easy to use online tool to convert your data.
Base64 Encode and Decode - Online
Encode to Base64 format or decode from it with various advanced options. Our site has an easy to use online tool to convert your data.

References

Understand Base64 Padding
Padding refers to the addition of “0s” to the left of a number to satisfy the length requirements. Understand Base64 Padding is discussed in this article.

Subscribe to Post, Code and Quiet Time.

Don’t miss out on the latest issues. Sign up now to get access to the library of members-only issues.
jamie@example.com
Subscribe