Problem: decoding Fz + =, and then encoding it returns Fz8 =
The following code:
new String(Base64.getEncoder().encode(Base64.getDecoder().decode("Fz+=".getBytes("UTF-8"))))
Gives the following line: FZ8 =
How did + become 8?
Something is missing for me.
Fz + = in the bit scheme: 000101 110011 111110 000 000
regrouped into 8-bit groups: 00010111 00111111 10000000
Decimal: 23 63 128
which will require 3 bytes to represent it.
However, when I try only this code:
Base64.getDecoder().decode("Fz+=".getBytes("UTF-8"))
I get the following array in decimal form:
[23, 63]
Where did the last byte (1000 0000) go? This is the reason the + symbol turned into 8 when we encoded it.
source
share