VBS Base64 decryption script code _vbs

Source: Internet
Author: User
Tags base64 chr

Copy Code code as follows:

Function Fdecode (Sstringtodecode)
' This function would decode a BASE64 encoded string and returns the decoded string.
' This becomes usefull if attempting to hide passwords from prying eyes.
Const CharList = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz0123456789+/"
Dim idatalength, soutputstring, Igroupinitialcharacter
Sstringtodecode = replace (replace (Sstringtodecode, VbCrLf, ""), VbTab, ""), "", "" "
Idatalength = Len (Sstringtodecode)
If idatalength Mod 4 <> 0 Then
Fdecode = "Bad string passed to Fdecode () function."
Exit Function
End If
For igroupinitialcharacter = 1 to idatalength step 4
Dim Idatabytecount, Icharactercounter, Scharacter, Idata, Igroup, spreliminaryoutstring
Idatabytecount = 3
Igroup = 0
For icharactercounter = 0 to 3
Scharacter = Mid (Sstringtodecode, Igroupinitialcharacter + icharactercounter, 1)
If Scharacter = "=" Then
Idatabytecount = iDataByteCount-1
Idata = 0
Else
Idata = INSTR (1, CharList, Scharacter, 0)-1
If idata =-1 Then
Fdecode = "Bad string passed to Fdecode () function."
Exit Function
End If
End If
Igroup = Igroup + idata
Next
Igroup = Hex (igroup)
Igroup = String (6-len (igroup), "0") & Igroup
spreliminaryoutstring = Chr (CByte ("&h" & Mid (Igroup, 1, 2)) & Chr (CByte ("&h" & Mid (Igroup, 3, 2)) &A mp CHR (CByte ("&h" & Mid (Igroup, 5, 2))
soutputstring = soutputstring & Left (spreliminaryoutstring, Idatabytecount)
Next
Fdecode = soutputstring
End Function

Base64 Test Code:
Copy Code code as follows:

Function Fdecode (Sstringtodecode)
' This function would decode a BASE64 encoded string and returns the decoded string.
' This becomes usefull if attempting to hide passwords from prying eyes.
Const CharList = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz0123456789+/"
Dim idatalength, soutputstring, Igroupinitialcharacter
Sstringtodecode = replace (replace (Sstringtodecode, VbCrLf, ""), VbTab, ""), "", "" "
Idatalength = Len (Sstringtodecode)
If idatalength Mod 4 <> 0 Then
Fdecode = "Bad string passed to Fdecode () function."
Exit Function
End If
For igroupinitialcharacter = 1 to idatalength step 4
Dim Idatabytecount, Icharactercounter, Scharacter, Idata, Igroup, spreliminaryoutstring
Idatabytecount = 3
Igroup = 0
For icharactercounter = 0 to 3
Scharacter = Mid (Sstringtodecode, Igroupinitialcharacter + icharactercounter, 1)
If Scharacter = "=" Then
Idatabytecount = iDataByteCount-1
Idata = 0
Else
Idata = INSTR (1, CharList, Scharacter, 0)-1
If idata =-1 Then
Fdecode = "Bad string passed to Fdecode () function."
Exit Function
End If
End If
Igroup = Igroup + idata
Next
Igroup = Hex (igroup)
Igroup = String (6-len (igroup), "0") & Igroup
spreliminaryoutstring = Chr (CByte ("&h" & Mid (Igroup, 1, 2)) & Chr (CByte ("&h" & Mid (Igroup, 3, 2)) &A mp CHR (CByte ("&h" & Mid (Igroup, 5, 2))
soutputstring = soutputstring & Left (spreliminaryoutstring, Idatabytecount)
Next
Fdecode = soutputstring
End Function
MsgBox Fdecode ("D3d3lmpinteubmv0")

Friends who need to test encrypted code can access the Http://www.jb51.net/tools/base64.htm

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.