How to diagnose double-encoded Base64
Trace VDBzPQ== through its intermediate value T0s= back to OK. Use the intermediate bytes to find the step that encoded an existing Base64 string.
Keep the first decoded value
Encoding the two letters OK produces T0s=. A second system that treats these four printable characters as fresh input produces VDBzPQ==. Decode the outer value and record the intermediate string before changing anything else.
Work backward through the two rows
The first row starts with the two message bytes. The second row starts with the four characters spelling the first Base64 result. Reverse the operations in the decoder. You should see four bytes after the outer decode and two after the inner one.
| Input | Bytes in hexadecimal | Base64 |
|---|---|---|
OK | 4F 4B | T0s= |
T0s= | 54 30 73 3D | VDBzPQ== |
Use the field contract as a stopping rule
Find out whether the sender expects raw bytes or pre-encoded text. Compare values immediately before and after any SDK or storage layer that transforms that field. A message could legitimately contain the literal text T0s=. Repeatedly decoding everything that resembles Base64 can silently change the intended message.