Index: /trunk/include/iprt/base64.h
===================================================================
--- /trunk/include/iprt/base64.h	(revision 73586)
+++ /trunk/include/iprt/base64.h	(revision 73587)
@@ -43,4 +43,14 @@
 # define RTBASE64_EOL_SIZE      (sizeof("\n")   - 1)
 #endif
+
+
+/** @name Flags for RTBase64EncodeEx() and RTBase64EncodedLengthEx().
+ * @{ */
+/** Insert line breaks into encoded string.
+ * The size of the end-of-line marker is that that of the host platform.
+ */
+#define RTBASE64_FLAGS_NO_LINE_BREAKS RT_BIT_32(0)
+/** @} */
+
 
 /**
@@ -121,11 +131,8 @@
                              size_t *pcbActual, char **ppszEnd);
 
+
 /**
  * Calculates the length of the Base64 encoding of a given number of bytes of
- * data.
- *
- * This will assume line breaks every 64 chars. A RTBase64EncodedLengthEx
- * function can be added if closer control over the output is found to be
- * required.
+ * data produced by RTBase64Encode().
  *
  * @returns The Base64 string length.
@@ -135,10 +142,18 @@
 
 /**
+ * Calculates the length of the Base64 encoding of a given number of bytes of
+ * data produced by RTBase64EncodeEx() with the same @a fFlags.
+ *
+ * @returns The Base64 string length.
+ * @param   cbData      The number of bytes to encode.
+ * @param   fFlags      Flags, any combination of the RTBASE64_FLAGS \#defines.
+ */
+RTDECL(size_t) RTBase64EncodedLengthEx(size_t cbData, uint32_t fFlags);
+
+/**
  * Encodes the specifed data into a Base64 string, the caller supplies the
  * output buffer.
  *
- * This will make the same assumptions about line breaks and EOL size as
- * RTBase64EncodedLength() does. A RTBase64EncodeEx function can be added if
- * more strict control over the output formatting is found necessary.
+ * This is equivalent to calling RTBase64EncodeEx() with no flags.
  *
  * @returns IRPT status code.
@@ -154,4 +169,21 @@
 RTDECL(int) RTBase64Encode(const void *pvData, size_t cbData, char *pszBuf, size_t cbBuf, size_t *pcchActual);
 
+/**
+ * Encodes the specifed data into a Base64 string, the caller supplies the
+ * output buffer.
+ *
+ * @returns IRPT status code.
+ * @retval  VERR_BUFFER_OVERFLOW if the output buffer is too small. The buffer
+ *          may contain an invalid Base64 string.
+ *
+ * @param   pvData      The data to encode.
+ * @param   cbData      The number of bytes to encode.
+ * @param   pszBuf      Where to put the Base64 string.
+ * @param   cbBuf       The size of the output buffer, including the terminator.
+ * @param   pcchActual  The actual number of characters returned.
+ */
+RTDECL(int) RTBase64EncodeEx(const void *pvData, size_t cbData, uint32_t fFlags,
+                             char *pszBuf, size_t cbBuf, size_t *pcchActual);
+
 /** @}  */
 
Index: /trunk/include/iprt/mangling.h
===================================================================
--- /trunk/include/iprt/mangling.h	(revision 73586)
+++ /trunk/include/iprt/mangling.h	(revision 73587)
@@ -575,5 +575,7 @@
 # define RTBase64DecodedSizeEx                          RT_MANGLER(RTBase64DecodedSizeEx)
 # define RTBase64Encode                                 RT_MANGLER(RTBase64Encode)
+# define RTBase64EncodeEx                               RT_MANGLER(RTBase64EncodeEx)
 # define RTBase64EncodedLength                          RT_MANGLER(RTBase64EncodedLength)
+# define RTBase64EncodedLengthEx                        RT_MANGLER(RTBase64EncodedLengthEx)
 # define RTBldCfgCompiler                               RT_MANGLER(RTBldCfgCompiler)
 # define RTBldCfgRevision                               RT_MANGLER(RTBldCfgRevision)
Index: /trunk/src/VBox/Runtime/common/string/base64.cpp
===================================================================
--- /trunk/src/VBox/Runtime/common/string/base64.cpp	(revision 73586)
+++ /trunk/src/VBox/Runtime/common/string/base64.cpp	(revision 73587)
@@ -400,9 +400,5 @@
 /**
  * Calculates the length of the Base64 encoding of a given number of bytes of
- * data.
- *
- * This will assume line breaks every 64 chars. A RTBase64EncodedLengthEx
- * function can be added if closer control over the output is found to be
- * required.
+ * data produced by RTBase64Encode().
  *
  * @returns The Base64 string length.
@@ -410,4 +406,19 @@
  */
 RTDECL(size_t) RTBase64EncodedLength(size_t cbData)
+{
+    return RTBase64EncodedLengthEx(cbData, 0);
+}
+RT_EXPORT_SYMBOL(RTBase64EncodedLength);
+
+
+/**
+ * Calculates the length of the Base64 encoding of a given number of bytes of
+ * data produced by RTBase64EncodeEx() with the same @a fFlags.
+ *
+ * @returns The Base64 string length.
+ * @param   cbData      The number of bytes to encode.
+ * @param   fFlags      Flags, any combination of the RTBASE64_FLAGS \#defines.
+ */
+RTDECL(size_t) RTBase64EncodedLengthEx(size_t cbData, uint32_t fFlags)
 {
     if (cbData * 8 / 8 != cbData)
@@ -419,5 +430,6 @@
         cch /= 6;
 
-        cch += ((cch - 1) / RTBASE64_LINE_LEN) * RTBASE64_EOL_SIZE;
+        if ((fFlags & RTBASE64_FLAGS_NO_LINE_BREAKS) == 0) /* add EOLs? */
+            cch += ((cch - 1) / RTBASE64_LINE_LEN) * RTBASE64_EOL_SIZE;
         return cch;
     }
@@ -428,8 +440,9 @@
     cch /= 6;
 
-    cch += ((cch - 1) / RTBASE64_LINE_LEN) * RTBASE64_EOL_SIZE;
+    if ((fFlags & RTBASE64_FLAGS_NO_LINE_BREAKS) == 0) /* add EOLs? */
+        cch += ((cch - 1) / RTBASE64_LINE_LEN) * RTBASE64_EOL_SIZE;
     return cch;
 }
-RT_EXPORT_SYMBOL(RTBase64EncodedLength);
+RT_EXPORT_SYMBOL(RTBase64EncodedLengthEx);
 
 
@@ -438,7 +451,5 @@
  * output buffer.
  *
- * This will make the same assumptions about line breaks and EOL size as
- * RTBase64EncodedLength() does. A RTBase64EncodeEx function can be added if
- * more strict control over the output formatting is found necessary.
+ * This is equivalent to calling RTBase64EncodeEx() with no flags.
  *
  * @returns IRPT status code.
@@ -453,4 +464,26 @@
  */
 RTDECL(int) RTBase64Encode(const void *pvData, size_t cbData, char *pszBuf, size_t cbBuf, size_t *pcchActual)
+{
+    return RTBase64EncodeEx(pvData, cbData, 0, pszBuf, cbBuf, pcchActual);
+}
+RT_EXPORT_SYMBOL(RTBase64Encode);
+
+
+/**
+ * Encodes the specifed data into a Base64 string, the caller supplies the
+ * output buffer.
+ *
+ * @returns IRPT status code.
+ * @retval  VERR_BUFFER_OVERFLOW if the output buffer is too small. The buffer
+ *          may contain an invalid Base64 string.
+ *
+ * @param   pvData      The data to encode.
+ * @param   cbData      The number of bytes to encode.
+ * @param   pszBuf      Where to put the Base64 string.
+ * @param   cbBuf       The size of the output buffer, including the terminator.
+ * @param   pcchActual  The actual number of characters returned.
+ */
+RTDECL(int) RTBase64EncodeEx(const void *pvData, size_t cbData, uint32_t fFlags,
+                             char *pszBuf, size_t cbBuf, size_t *pcchActual)
 {
     /*
@@ -483,14 +516,17 @@
         pbSrc  += 3;
 
-        /* deal out linefeeds */
-        if (cbBuf == cbLineFeed && cbData)
-        {
-            if (cbBuf < RTBASE64_EOL_SIZE + 1)
-                return VERR_BUFFER_OVERFLOW;
-            cbBuf -= RTBASE64_EOL_SIZE;
-            if (RTBASE64_EOL_SIZE == 2)
-                *pchDst++ = '\r';
-            *pchDst++ = '\n';
-            cbLineFeed = cbBuf - RTBASE64_LINE_LEN;
+        if ((fFlags & RTBASE64_FLAGS_NO_LINE_BREAKS) == 0) /* add EOLs? */
+        {
+            /* deal out end-of-line */
+            if (cbBuf == cbLineFeed && cbData)
+            {
+                if (cbBuf < RTBASE64_EOL_SIZE + 1)
+                    return VERR_BUFFER_OVERFLOW;
+                cbBuf -= RTBASE64_EOL_SIZE;
+                if (RTBASE64_EOL_SIZE == 2)
+                    *pchDst++ = '\r';
+                *pchDst++ = '\n';
+                cbLineFeed = cbBuf - RTBASE64_LINE_LEN;
+            }
         }
     }
@@ -530,4 +566,3 @@
     return VINF_SUCCESS;
 }
-RT_EXPORT_SYMBOL(RTBase64Encode);
-
+RT_EXPORT_SYMBOL(RTBase64EncodeEx);
