Vbs base64 decryption script code

Source: Internet
Author: User

CopyCode The Code is as follows: function fdecode (sstringtodecode)
'This function will decode a base64 encoded string and returns the decoded string.
'This becomes usefull when 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 = 64 * 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) & CHR (cbyte ("& H" & Mid (igroup, 5, 2 )))
Soutputstring = soutputstring & left (spreliminaryoutstring, idatabytecount)
Next
Fdecode = soutputstring
End Function

Base64 test code:Copy code The Code is as follows: function fdecode (sstringtodecode)
'This function will decode a base64 encoded string and returns the decoded string.
'This becomes usefull when 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 = 64 * 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) & 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 the 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.