Dependents:   TimeZoneDemo EthernetJackTestCode MMEx_Challenge ntp_mem ... more

Revision:
5:fa27dde97304
Parent:
0:ac1725ba162c
--- a/services/http/util/base64.h	Sun Nov 21 17:13:44 2010 +0000
+++ b/services/http/util/base64.h	Sat Nov 27 23:23:43 2010 +0000
@@ -33,7 +33,7 @@
 
 //Originaly from Rolf's iputil.h
 
-unsigned int base64enc_len(const char *str);
+unsigned int base64enc_len(const char* str);
 
 void base64enc(const char *input, unsigned int length, char *output);
 
@@ -44,9 +44,14 @@
 class Base64
 {
 public:
+  static unsigned int base64enc_len(const string& str)
+  {
+    return (((str.length()-1)/3)+1)<<2;
+  }
+
   static string encode(const string& str)
   {
-    char* out = new char[ base64enc_len(str.c_str()) ];
+    char* out = new char[ base64enc_len(str) ];
     base64enc(str.c_str(), str.length(), out);
     string res(out);
     delete[] out;