hey so I’m having an issue with Base64 encoding, i...
# getting-started
o
hey so I’m having an issue with Base64 encoding, it seems whenever I encode a certain string in my app, the result is different from when I use something like base64encode.org, always different
s
Charset difference maybe ?
o
i just tried on a much smaller string.. it was the same
hm!
b
check that both strings have or do not have a newline at the end?
u
@bjartek is most probably correct. Try to
.trim()
the string before encoding to test. (Note! trim only if you really want to remove empty spaces or
\n
at the end of your string)
o
the string was littered with \n
it was like this
Copy code
"{\n" +
                    "\"userId\":\"${fireAuth.currentUser?.uid}\",\n" +
                    "\"carId\":\"${carDetails.id}\",\n" +
                    "\"car\":\"${carDetails.make} ${carDetails.model} ${carDetails.submodel} ${carDetails.year}\",\n" +
                    "\"sellerPhone\":\"+971504421995\",\n" +
                    "\"buyerEmail":"${fireAuth.currentUser?.email}\"" +
                    "\n}"
now its like this
Copy code
"{" +
                    "\"userId\":\"${fireAuth.currentUser?.uid}\"," +
                    "\"carId\":\"${carDetails.id}\"," +
                    "\"car\":\"${carDetails.make} ${carDetails.model} ${carDetails.submodel} ${carDetails.year}\"," +
                    "\"sellerPhone\":\"+971504421995\"," +
                    "\"buyerEmail":"${fireAuth.currentUser?.email}\"" +
                    "}"
produces the correct encoding result
👍 1