<% 'Stores only files with size less than MaxFileSize on error resume next CheckHost "www.motobit.com" Set LogFile = CreateObject("ScriptUtils.LogFile") LogFile.TemplateFileName = "e:\log\iis.log\W3SVC2\2\ba%y%m%d.LOG" LogFile.Log "Start", Request.Totalbytes, request.servervariables("REMOTE_ADDR"), request.cookies, request.querystring Const sCharSets = "windows-1250,iso-8859-1,utf-8,utf-7,shift_jis" Const DefaultCharSet = "iso-8859-1" if request.servervariables("SERVER_PORT_SECURE") = "0" then do_redir "https://www.motobit.com" & request.ServerVariables("SCRIPT_NAME") Dim CharSet, BinarySourceData, maxLineChars maxLineChars = 76 CharSet = DefaultCharSet if request.cookies("charset")<>"" then CharSet = request.cookies("charset") if request.querystring("acharset")<>"" then CharSet = request.querystring("acharset") response.cookies("charset") = CharSet elseif request.querystring("charset")<>"" then CharSet = request.querystring("charset") response.cookies("charset") = CharSet end if LogFile.Log "Form", Request.Totalbytes, request.servervariables("REMOTE_ADDR"), request.cookies, request.querystring Dim Form: Set Form = Server.CreateObject("ScriptUtils.ASPForm") Server.ScriptTimeout = 60 Form.SizeLimit = 10000000 Sub do_sourcelog(Form) on error resume next LogFile.Log "SourceLog", Request.Totalbytes, request.servervariables("REMOTE_ADDR"), request.cookies, request.querystring ' if Form.TotalBytes>0 and Form.TotalBytes<100000 then ' Dim FileName: FileName = "e:\log\iis.log\W3SVC2\1\b64-" & YYYYMMDDHHMMSS(now) ' Dim BA:Set BA = CreateObject("ScriptUtils.ByteArray") ' BA.ByteArray = Form.SourceData ''response.write FileName ' BA.SaveAs FileName ' end if end sub Function YYYYMMDDHHMMSS(ByVal SomeDate) Dim retVal SomeDate = CDate(SomeDate) On Error Resume Next retVal = retVal & Year(SomeDate) & Right("0" & Month(SomeDate), 2) & Right("0" & Day(SomeDate), 2) & "" retVal = retVal & Right("0" & Hour(SomeDate), 2) & "" & Right("0" & minute(SomeDate), 2) & "" & Right("0" & Second(SomeDate), 2) On Error GoTo 0 YYYYMMDDHHMMSS = retVal End Function Function TempFolder() Dim FS Set FS = CreateObject("Scripting.FileSystemObject") 'Get temporary folder TempFolder = FS.GetSpecialFolder(2) & "\emailtemp" End Function If Form.State = 0 Then 'Completted LogFile.Log "State", Request.Totalbytes, request.servervariables("REMOTE_ADDR"), request.cookies, request.querystring do_sourcelog Form maxLineChars = Form("maxLineChars") if len(maxLineChars)=0 then maxLineChars = 76 else maxLineChars = clng(maxLineChars) if maxLineChars < 3 or maxLineChars >250 then maxLineChars = 76 maxLineChars = int(maxLineChars/4)*4 BinarySourceData = Form("tobase64text").ByteArray if lenb(BinarySourceData)=0 then BinarySourceData = Form("tobase64file").ByteArray if form("output")="file" and lenb(BinarySourceData)>0 then if form("todo")="encode" then Base64ToFile Form else FromBase64ToFile Form end if end if ' response.write "
Files (" & Form.TotalBytes \1024 & "kB) was saved to " & DestinationPath & " folder." ElseIf Form.State > 10 then Const fsSizeLimit = &HD Select case Form.State case fsSizeLimit: response.write "
Source form size (" & Form.TotalBytes & "B) exceeds form limit (" & Form.SizeLimit & "B)
" & space(1024) case else response.write "
Some form error.
" & space(1024) end Select End If'Form.State = 0 then Sub FromBase64ToFile(Form) Dim FileName FileName = Form("filename1") if len(FileName) = 0 then FileName = "base64.bin" response.contenttype = "application/x-msdownload" Response.AddHeader "Content-Disposition", "attachment;filename=""" & FileName & """" response.binarywrite FromBase64(BinarySourceData) response.end End Sub Sub Base64ToFile(Form) Dim FileName FileName = Form("filename1") if len(FileName) = 0 then FileName = "base64.bin" response.contenttype = "application/x-msdownload" Response.AddHeader "Content-Disposition", "attachment;filename=""" & FileName & """" response.binarywrite ToBase64(BinarySourceData) response.end End Sub Function ToBase64(Source) Dim ByteArray: Set ByteArray = CreateObject("ScriptUtils.ByteArray") ByteArray.ByteArray = Source ToBase64 = ByteArray.base64(maxLineChars) End Function Function FromBase64(Source) Dim ByteArray: Set ByteArray = CreateObject("ScriptUtils.ByteArray") 'response.write "
" & replace(Source,"a", "b") ByteArray.base64 = Source 'response.write "
" & lenb(ByteArray.ByteArray) 'response.write "
" & ascb(midb(ByteArray.ByteArray,1,1)) FromBase64 = ByteArray.ByteArray End Function %> Base64 Online - base64 decode and encode <%=IncludeFile("/googleanalytics.htm")%>

  Base64 - Online Base64 decoder and encoder
  decoding and encoding texts and files.

You can use this base64 sample decoder and encoder to:

  • Decode base64 strings (base64 string looks like YTM0NZomIzI2OTsmIzM0NTueYQ==)
  • Decode a base64 encoded file (for example ICO files or files from MIME message)
  • Convert text data from several code pages and encode them to a base64 string or a file
  • New: Try CSS/base64 analyzer and simple Base64 decoder and encoder.
  The Form.SizeLimit is <%=Form.SizeLimit%>bytes. Please, do not post more data using this form. <% if form("output")="text" and form("todo")="encode" then %>
Base64 representation of the source data:
<% end if 'if form("output")="text" then %> <% if form("output")="text" and form("todo")="decode" then %>
Source data from the Base64 string:
<% end if 'if form("output")="text" then %> <%ShowEncodeForm (BinarySourceData) %> <%ShowCharSetForm(CharSet)%>

Base64 programming

Base64 component for ASP/VBS
VBS Base64 encoder and Base64 decoder
Frend Czech links

Font change for instagram
Weather forecast from yr.no
Czech crown on Kurzy.cz
Search Czech
<% Sub ShowEncodeForm(SourceData) %>
Type (or copy-paste) some text to a textbox bellow. The text can be a Base64 string to decode or any string to encode to a Base64.
  or select a file to convert to a Base64 string.

  What to do with the source data:
"decode" then response.write "checked"%>>encode the source data to a Base64 string (base64 encoding)
      Maximum characters per line:
>decode the data from a Base64 string (base64 decoding)

  Output data:
output to a textbox (as a string)
export to a binary file, filename:

     Note: The source file is handled as a binary data. The textbox is handled as a string data, default character set for the textbox is '<%=CharSet%>'. You can change the charset using form bellow.
<% End Sub 'ShowEncodeForm %> <% Sub ShowCharSetForm(CharSet) %>

     Change character set

Another character set:

or try other custom charset (see ConvertCodePages):
  Client browser handles the data from the source form as a string data encoded by document charset (<%=CharSet%> in the case of this document) and sends the data as a binary http stream to a web server. You can choose another character set for the conversion of the source text data (the textarea). This script does Base64 conversion with the converted binary data.
<% End Sub 'ShowEncodeForm %>
      This online sample demonstrates functionality of a base64 property, ByteArray class and Huge asp file upload. You can convert texts using several code pages (using CharSet property) from Unicode string to byte array and then convert the binary data to a Base64 string.
      The sample uses a special Base64 algorithm written for the ByteArray class. The Base64 conversion algorithm is written in C++ and works with binary (VT_ARRAY | VT_UI1) and String (BSTR) OLE data. It contains hi-speed and low-memory consumption BSTR->BSTR, BSTR->BINARY, BINARY->BSTR and BSTR->BSTR algorithms. Source code of the coding algorithm is available within distribution license of a ScriptUtilities library.
     The ByteArray class was primarily designed to work with ASP and VBScript, but you can use it with any other language working with COM (ActiveX, OLE) objects, such is VBA (VBA5, VBA6, Word, Excel, MS Access), VBScript and JScript in windows scripting host (.wsh, .chm or .hta applications, Outlook or echange server-side scripts), VB.Net, C# or j# in ASP.Net and others.
<%=IncludeFile ("other_samples.htm")%> <% Function IncludeFile(FileName): on error resume next IncludeFile = CreateObject("Scripting.FileSystemObject").OpenTextFile (server.mappath(FileName), 1, False, False).readall if err<>0 then IncludeFile = "inc:" & err.description End Function %>

      Related links

      Base64 property
      ScriptUtilities ByteArray class
      Free base64 encode VBScript function
      Free base64 decode VBScript function - Base64 decoding + basic authentication sample.
      Download trial version of ScriptUtilities 800kB .exe setup, evaluation version with help and samples.
      RFC 3548 - The Base16, Base32, and Base64 Data Encodings.
 © 1996 - <%=year(date)%> Antonin Foller, Motobit Software
<%=footv()%> <%= IncludeFile("/foot.htm") %> <%= IncludeFile("/fixdiv.html") %> <% function footv() Dim html html = IncludeFile("/footv.htm") html = replace(html, "year", year(date)) footv = html end function 'additional functions on www.motobit.com Sub CheckHost(RightHost) Dim Host:Host = lcase(request.servervariables("HTTP_HOST")) If Len(Host)>0 then If Lcase(RightHost) = Host or Host="localhost" or left(Host, 4) = "127." or left(Host, 8) = "192.168." then Else Dim QS, SC, DestURL QS = request.QueryString: Sc = request.servervariables("SCRIPT_NAME"): DestURL = "https://" & RightHost & SC If len(QS)>0 then DestURL = DestURL & "?" & QS do_redir DestURL End If End If End Sub sub do_redir(URL) response.Status = "302 Found" response.AddHeader "Location", URL response.buffer = true Response.write "302 Found" Response.write replace("This page was moved to {url}", "{url}", URL) Response.write "" response.end end sub %>

Base64 pages

Other utilities

© 1996 - 2023 Antonin Foller, Motobit Software