WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Conversion UDFs

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

udfEncodeBase64

 Keywords: udfEncodeBase64 Encode Base64 MSXML ChrStringToHex BinaryPokeHex BinaryOleType MSXML2.DOMDocument nodeTypedValue

#DefineFunction udfEncodeBase64(str)
   ;Reference:  http://msdn.microsoft.com/en-us/library/windows/desktop/ms762308(v=vs.85).aspx
   hexstr = ChrStringToHex(str)
   hBin = BinaryAlloc(StrByteCount( hexstr, 1 ))
   BinaryPokeHex(hBin, 0, hexstr)
   BinaryOleType(hBin, 103, 0,0,0)
   objXML = ObjectCreate('MSXML2.DOMDocument')
   objNode = objXML.createElement("b64")
   objNode.dataType = "bin.base64"
   objNode.nodeTypedValue = hBin
   EncodeBase64 = objNode.Text
   objNode = 0
   objXML = 0
   Return EncodeBase64
#EndFunction

text = 'JoeBlow:Bubblegum' ;username:Password
strencoded = udfEncodeBase64(text)
Pause('udfEncodeBase64(str)',strencoded)
Exit

Article ID:   W18348
Filename:   udfEncodeBase64.txt
File Created: 2013:02:25:14:51:16
Last Updated: 2013:02:25:14:51:16