Own fork of MbedSmartRest

Dependents:   MbedSmartRestMain MbedSmartRestMain

Fork of MbedSmartRest by Cumulocity Official

Revision:
22:832cb27c28f9
Parent:
20:505d29d5bdfc
--- a/b64.cpp	Mon Apr 20 15:03:44 2015 +0000
+++ b/b64.cpp	Mon Apr 27 10:50:03 2015 +0000
@@ -18,18 +18,17 @@
 }
 */
 
-int b64_encode(const unsigned char* aInput, int aInputLen, unsigned char* aOutput, int aOutputLen)
+const char* b64_dictionary = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+
+void b64_encode(const unsigned char* aInput, int aInputLen, unsigned char* aOutput, int aOutputLen)
 {
     // Work out if we've got enough space to encode the input
     // Every 6 bits of input becomes a byte of output
-    if (aOutputLen < (aInputLen*8)/6) {
+    if (aOutputLen*6 < aInputLen*8) {
         // FIXME Should we return an error here, or just the length
-        return (aInputLen*8)/6;
+        return ;
     }
 
-    // If we get here we've got enough space to do the encoding
-
-    const char* b64_dictionary = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
     if (aInputLen == 3)
     {
         aOutput[0] = b64_dictionary[aInput[0] >> 2];