is there any function or library that can encode data using base64 encoding..? in nrf51422
is there any function or library that can encode data using base64 encoding..? in nrf51422
Hi,
Take a look at the ARM crypto lib (GPL license) or implement it directly from the RFC here. It is quite a simple procedure, more about re-grouping bits than anything else.
When encoding to base64, the output size will increase by a factor of about 4/3. This is because every 3 bytes are encoded into 4 bytes, and finally padded to always be a multiple of 4 bytes. So the destination array needs to be larger. A more precise size than 4/3 is (src_length + 2 - ((src_length + 2) % 3)) / 3 * 4. You should then get that your string encodes into "ADUAAAAAAAAAADU=", which is reversed properly back to your start array.
When encoding to base64, the output size will increase by a factor of about 4/3. This is because every 3 bytes are encoded into 4 bytes, and finally padded to always be a multiple of 4 bytes. So the destination array needs to be larger. A more precise size than 4/3 is (src_length + 2 - ((src_length + 2) % 3)) / 3 * 4. You should then get that your string encodes into "ADUAAAAAAAAAADU=", which is reversed properly back to your start array.