VBScript base64_decode function

A VBScript equivalent of PHP’s base64_decode


Function base64_decode(data)

    Dim obj
    set obj=server.createobject("basp21")
    base64_decode = obj.Base64(data,1)
    set obj = nothing

    '
    'not use BASP21
    '

'    Dim ST, DM, EL
'    Dim bin
' 
'    Set DM = CreateObject("Microsoft.XMLDOM")
'    Set EL = DM.createElement("tmp")
'    EL.DataType = "bin.base64"
'    EL.Text = Base64Text
'    bin = EL.NodeTypedValue
' 
'    Set ST = CreateObject("ADODB.Stream")
'    ST.Open
'    ST.Charset = "Shift-JIS"
'    ST.Type = adTypeBinary
'    ST.Write bin
'    ST.Position = 0
'    ST.Type = adTypeText
'    base64_decode = ST.ReadText
End Function

Please also note that php.vbs offers community built functions and goes by the McDonald’s Theory. We’ll put online functions that are far from perfect, in the hopes to spark better contributions. Do you have one? Then please just:

Other PHP functions in the url extension