Main Software ActiveX ASP Source Downloads Android Contact
ASP

Here you can find some FREE usefull Classic ASP / VBScript code snippets, class modules, etc.
I use then myself on most of my projects, so you can rest assured they were optimized over time and are very reliable.
You can use them on your personal or commercial projects.
If you find them usefull to you, please make a donation (nomatter how small) to help me keep this content online for free.


Encode and Decode String File IO Misc
Base-64
HTML2Text
Recaptcha
SHA-1
Text2HTML
Escape
FileNameIn
FileSizeDesc
Format
RemoveTags
BinReadFile
CreateFolder
FileDateTime
FileExists
FileLen
FolderExists
GetFiles
GetFolders
ReadFile
IsValidEmail
SendCDOMail
ScanVar
Class Base64 Simple base-64 encode and decode class. Methods Encode (string_to_encode) Method Encode a String to base-64 and returns the encoded String. Decode (base64_encoded_string) Method Decodes a base-64 encoded String and returns de decoded String.
Example
<%
dim b64, my_string,ms_encoded, ms_decoded
my_string = "This is my String! Take good care of it!"
set b64 = new Base64
ms_encoded=b64.Encode(my_string)
ms_decoded=b64.Decode(ms_encoded)
response.write "Original string: " & my_string & "<br>"
response.write "Encoded string: " & ms_encoded & "<br>"
response.write "Decoded string: " & ms_Decoded & "<br>"
set b64 = nothing
%>


Source Code
<%
Class Base64

dim b64Dic

Public Function Decode(byval s)
Dim w1, w2, w3, w4, n, res, i, cc
redim res(0): i=0
for n=1 to len(s) step 4
   cc=mid(s,n,1): if cc="" then w1=-1 else w1=inStr(b64Dic,cc)-1
   cc=mid(s,n+1,1): if cc="" then w2=-1 else w2=inStr(b64Dic,cc)-1
   cc=mid(s,n+2,1): if cc="" then w3=-1 else w3=inStr(b64Dic,cc)-1
   cc=mid(s,n+3,1): if cc="" then w4=-1 else w4=inStr(b64Dic,cc)-1
   if w2>=0 then
      redim preserve res(i): i=i+1
      res(i-1)=chr(((w1*4+int(w2/16)) and 255))
      end if
   if w3>=0 then
      redim preserve res(i): i=i+1
      res(i-1)=chr(((w2*16+int(w3/4)) and 255))
      end if
   if w4>=0 then
      redim preserve res(i): i=i+1
      res(i-1)=chr(((w3*64+w4) and 255))
   end if
Next
Decode = join(res,"")
redim res(0): erase res
End Function

Public Function Encode(byval s)
Dim res, i, c1, c2, c3, w1, w2, w3, w4, n
redim res(0): i=0
for n=1 to len(s) step 3
   c1=asc(mid(s,n,1)): c2=asc(mid(s,n+1,1)+chr(0)): c3=asc(mid(s,n+2,1)+chr(0))
   w1=int(c1/4): w2=(c1 and 3)*16+int(c2/16)
   if len(s)>=n+1 then w3=(c2 and 15)*4+int(c3/64) else w3=-1
   if len(s)>=n+2 then w4=c3 and 63 else w4=-1
   redim preserve res(i): i=i+1
   if w1>=0 then res(i-1)=mid(b64Dic,w1+1,1)
   redim preserve res(i): i=i+1
   if w2>=0 then res(i-1)=mid(b64Dic,w2+1,1)
   redim preserve res(i): i=i+1
   if w3>=0 then res(i-1)=mid(b64Dic,w3+1,1)
   redim preserve res(i): i=i+1
   if w4>=0 then res(i-1)=mid(b64Dic,w4+1,1)
next
Encode = join(res,"")
redim res(0): erase res
End Function

private sub Class_Initialize()
b64Dic = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
end sub

End Class
%>