Index: tol/bbasic/tol_btext.h
===================================================================
--- tol/bbasic/tol_btext.h	(revision c3a68a9c7b85a36cc6f5f0a60c540c36ebe3197f)
+++ tol/bbasic/tol_btext.h	(revision 1ecde2036b2c4bc6cea7c3d79298e9a733f9d461)
@@ -485,4 +485,9 @@
   void ReallocateBuffer(BInt newSize);
 
+  void base64_encode(const BArray<unsigned char>& binary);
+  int base64_decode(BArray<unsigned char>& binary) const;
+  void base64_encode_from_file(const BText& path);
+  int base64_decode_to_file(const BText& path) const;
+
  private:
 
@@ -706,4 +711,7 @@
 }
 
+std::string base64_encode(const BArray<unsigned char>& binary);
+int base64_decode(BArray<unsigned char>& binary, std::string const& encoded_string);
+
 #endif // TOL_BTEXT_H
 
Index: tol/bbasic/txtalgeb.cpp
===================================================================
--- tol/bbasic/txtalgeb.cpp	(revision c3a68a9c7b85a36cc6f5f0a60c540c36ebe3197f)
+++ tol/bbasic/txtalgeb.cpp	(revision 1ecde2036b2c4bc6cea7c3d79298e9a733f9d461)
@@ -28,4 +28,5 @@
 #include <tol/tol_btimer.h>
 #include <tol/tol_barray.h>
+#include <tol/tol_bdir.h>
 //#include <tol/tol_bfilter.h> no parece que haga falta aqui
 
@@ -1598,5 +1599,5 @@
   }
   length_ = 0;
-  BChar ch  = 0, c;
+  BChar ch  = 0, c = 0;
   bool untilIsLF = until=='\n';
   for(;(length_<=maxChars)&&(ch!=until)&&(!feof(file)); length_++)
@@ -1798,2 +1799,173 @@
 
 
+
+static const std::string base64_chars = 
+             "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+             "abcdefghijklmnopqrstuvwxyz"
+             "0123456789+/";
+
+
+//--------------------------------------------------------------------
+static inline bool is_base64(unsigned char c) 
+//--------------------------------------------------------------------
+{
+  return (isalnum(c) || (c == '+') || (c == '/'));
+}
+
+//--------------------------------------------------------------------
+std::string base64_encode(const BArray<unsigned char>& binary) 
+//--------------------------------------------------------------------
+{
+  unsigned char const* bytes_to_encode = binary.Buffer();
+  unsigned int in_len = binary.Size();
+  std::string ret;
+  int i = 0;
+  int j = 0;
+  unsigned char char_array_3[3];
+  unsigned char char_array_4[4];
+
+  while (in_len--) {
+    char_array_3[i++] = *(bytes_to_encode++);
+    if (i == 3) {
+      char_array_4[0] = (char_array_3[0] & 0xfc) >> 2;
+      char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4);
+      char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6);
+      char_array_4[3] = char_array_3[2] & 0x3f;
+
+      for(i = 0; (i <4) ; i++)
+        ret += base64_chars[char_array_4[i]];
+      i = 0;
+    }
+  }
+
+  if (i)
+  {
+    for(j = i; j < 3; j++)
+      char_array_3[j] = '\0';
+
+    char_array_4[0] = (char_array_3[0] & 0xfc) >> 2;
+    char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4);
+    char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6);
+    char_array_4[3] = char_array_3[2] & 0x3f;
+
+    for (j = 0; (j < i + 1); j++)
+      ret += base64_chars[char_array_4[j]];
+
+    while((i++ < 3))
+      ret += '=';
+
+  }
+
+  return ret;
+
+}
+
+//--------------------------------------------------------------------
+int base64_decode(BArray<unsigned char>& binary, std::string const& encoded_string) 
+//--------------------------------------------------------------------
+{
+  int in_len = encoded_string.size();
+  int i = 0;
+  int j = 0;
+  int in_ = 0;
+  unsigned char char_array_4[4], char_array_3[3];
+  int bin_len = (in_len * 2)/3 +1;
+  binary.AllocBuffer(bin_len);
+  binary.ReallocBuffer(0);
+
+  while (in_len-- && ( encoded_string[in_] != '=') && is_base64(encoded_string[in_])) {
+    char_array_4[i++] = encoded_string[in_]; in_++;
+    if (i ==4) {
+      for (i = 0; i <4; i++)
+        char_array_4[i] = base64_chars.find(char_array_4[i]);
+
+      char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4);
+      char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
+      char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3];
+
+      for (i = 0; (i < 3); i++)
+        binary.Add(char_array_3[i]);
+      i = 0;
+    }
+  }
+  if (i) {
+    for (j = i; j <4; j++)
+      char_array_4[j] = 0;
+
+    for (j = 0; j <4; j++)
+      char_array_4[j] = base64_chars.find(char_array_4[j]);
+
+    char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4);
+    char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
+    char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3];
+
+    for (j = 0; (j < i - 1); j++) { binary.Add(char_array_3[j]); }
+  }
+  return binary.Size();
+}
+
+//--------------------------------------------------------------------
+  void BText::base64_encode(const BArray<unsigned char>& binary)
+//--------------------------------------------------------------------
+{
+  std::string str = ::base64_encode(binary);
+  Copy(str.c_str(),str.length());
+}
+
+//--------------------------------------------------------------------
+  int BText::base64_decode(BArray<unsigned char>& binary) const
+//--------------------------------------------------------------------
+{
+  std::string str(String(), Length());
+  return(::base64_decode(binary, str));
+}
+
+//--------------------------------------------------------------------
+  void BText::base64_encode_from_file(const BText& path)
+//--------------------------------------------------------------------
+{
+  BDir dir(path);
+  bool ok = false;
+  if(dir.Exist() && dir.IsFile())
+  {
+    BArray<unsigned char> binary;
+    binary.AllocBuffer(dir.Bytes());
+    FILE *stream = fopen(path.String(),"rb");
+    if(stream)
+    {
+      fread(binary.GetBuffer(),1,binary.Size(),stream); 
+      fclose(stream);
+      ok = true;
+      base64_encode(binary);
+    }
+  }
+  if(!ok)
+  {
+    Error(BText("[base64_encode_from_file]: "
+      "cannot open file for reading:")+path); 
+    ReallocateBuffer(0);
+  }
+}
+
+//--------------------------------------------------------------------
+  int BText::base64_decode_to_file(const BText& path) const
+//--------------------------------------------------------------------
+{
+  BArray<unsigned char> binary;
+  int size = 0;
+  FILE *stream = fopen(path.String(),"wb");
+  if(stream)
+  {
+    size = base64_decode(binary);
+    fwrite(binary.Buffer(),1,binary.Size(),stream);   
+    fclose(stream);
+  }
+  else
+  {
+    Error(BText("[base64_decode_to_file]: "
+      "cannot open file for writing:")+path); 
+  }
+  return(size);
+}
+
+
Index: tol/btol/text_type/txtgra.cpp
===================================================================
--- tol/btol/text_type/txtgra.cpp	(revision c3a68a9c7b85a36cc6f5f0a60c540c36ebe3197f)
+++ tol/btol/text_type/txtgra.cpp	(revision 1ecde2036b2c4bc6cea7c3d79298e9a733f9d461)
@@ -1907,4 +1907,52 @@
 }
 
+//--------------------------------------------------------------------
+DeclareContensClass(BText, BTxtTemporary, BTxtEncodeBase64FromFile);
+DefExtOpr(1, BTxtEncodeBase64FromFile, "EncodeBase64FromFile",   1, 1, 
+  "Text",
+	I2("(Text fileName)",
+	   "(Text nombreFichero)"),
+	I2("Returns the contents of a binary file decoded with Base64 "
+     "algorithm (http://en.wikipedia.org/wiki/Base64). "
+     "If the file not exists returns "
+	   "the void string and displays a warning message.",
+	   "Devuelve el contenido de un fichero binario codificado con "
+     "el algoritmo Base64 (http://es.wikipedia.org/wiki/Base64). "
+     "Si el fichero no existe "
+	   "devuelve la cadena vacía y muestra un mensaje de advertencia."),
+	  BOperClassify::Text_);
+
+//--------------------------------------------------------------------
+void BTxtEncodeBase64FromFile::CalcContens()
+//--------------------------------------------------------------------
+{
+  BText& path = Text(Arg(1));
+  contens_.base64_encode_from_file(path);
+}
+
+
+//--------------------------------------------------------------------
+DeclareContensClass(BDat, BDatTemporary, BDatDecodeBase64ToFile);
+DefExtOpr(1, BDatDecodeBase64ToFile, "DecodeBase64ToFile", 2, 2, 
+  "Text Text",
+	I2("(Text fileName, Text encoded)",
+	   "(Text nombreFichero, Text encoded)"),
+	I2("Writes a binary a file with the result of decoding a text "
+     "using Base64 algorithm (http://en.wikipedia.org/wiki/Base64). "
+     "It returns the binary file size.",
+	   "Escribe un fichero binario con el resultado de descodificar un "
+     "texto usando el algoritmo Base64 "
+     "(http://es.wikipedia.org/wiki/Base64). Develve el tamaño del "
+     "fichero creado."),
+	BOperClassify::Text_);
+
+//--------------------------------------------------------------------
+void BDatDecodeBase64ToFile::CalcContens()
+//--------------------------------------------------------------------
+{
+  BText& path = Text(Arg(1));
+  BText& encoded = Text(Arg(2));
+  contens_ = encoded.base64_decode_to_file(path);
+}
 
 //--------------------------------------------------------------------
