I want to generate Base64 string for a specific image. for that I've wrote below code
let imageData = UIImagePNGRepresentation(imgProfile.image!)!
var imageStr = imageData.base64EncodedString(options: Data.Base64EncodingOptions.lineLength64Characters)
and I'm getting this output string as Base64 which is not decoded (i.e. wrong).
but when I'm generating Base64 from here, I'm getting this output string, which is successfully decoded and getting the image back (i.e. correct)
Please help me to find the issue.
Thanks in advance
I've already visited following threads.
1. https://stackoverflow.com/a/47610733/3110026
2. https://stackoverflow.com/a/46309421/3110026
data.base64EncodedString()only not with options?\n\r) after each 64 characters with the options you passed. What do you expect? To decode the string ignoring the new lines you have to pass.ignoreUnknownCharacters.lineLength64Charactersdoes that. The text in your link contains a lot of them. Please see my answer.