I am trying to get an UIImage from base64String but I am facing an interesting problem. Even though the encoded string is full, decoding it returns nil.
let base64String = imageFilePath as! String print(base64String) // returns encoded value let decodedData = NSData(base64EncodedString: base64String, options: NSDataBase64DecodingOptions(rawValue: 0)) print(decodedData) // returns nil
Edit: It goes like
24wKiOQeetKPWmsx3AjtQMe+cDApoOTinCTOOKUsF5osIbtK800E5yKRySeeKFf ZQA5m79KkjYHr1qMupHWkbJGVoGTE0majXceT0qQkAUCGEUo5GKYOT81S5AOKEND WUg0wg9BUu4dKibAOKYCAHFKOCCaQ9cGkBzQApbk5o3D7p/A0mRS9e1AD1BPSnCN RzQnA5pjHPFMdhWcgbVHFSggr0/
For my project user send me a base64 encoded code. I need to convert into pdf document.
I am using the below code for the same.
string AsBase64String = "base64code";byte tempBytes = Convert.FromBase64String(AsBase64String);File.WriteAllBytes(@"C:\d\hh.pdf", tempBytes);
and this is working successfully but in some cases it is generating the pdf. When opening the pdf it is showing it is not valid format.
I use the same code in the below online website
Pasted the code and decode it and saved as a file and try to open in pdf. It gave the same error. Then I open the file in notepad and copy the code inside and decode it in the above website again. Then save it as file. When i open the second file it opened successfully.
Steps I done
but most of the cases first decode itself open successfully in pdf. Rare cases it needed two time decoding.
What may be the trick happening here. I am new to this base64 decoding. Please show some light on this issue
I think I must have a fundamental gap in my knowledge, as I cannot work out how to find the answer to this (probably simple) question.
Here is the situation:
Here's my question - how do I extract/unzip/uncompress that string into a format I can view/access?
I know handling zipped files can be effortful, but is that what's going on here? Am I missing something? Maybe in the structure of the curl request?
Thank you for any help you can offer - it is very much appreciated!
I read that Base64 is deterministic algorithm, and produce unique results. Consider these two encoded base64 values:
These both give me same decoded output. How is this possible? I couldn't find any visible difference between decoded format of these two values.
Is it related to encoding and decoding schemes like UTF 8 and ASCII?
My hosting company has encrypted some data that I want decode, but it is not decoding although I know that it's base64.
Here is the code: