📄 解密.vbs
字号:
elseif HexLen <= 1 then
WScript.echo "Error From JudgeUnicode! The input Unicode Hex number """ & JudgeUnicode &_
""" is invalid(the length is: " & HexLen & ",it shouldn't be less than 2.)!"
WScript.Quit(1)
end if
JudgeUnicode = Ucase(JudgeUnicode)
end Function
Function Hex2Bin(byval HexValue)
dim i,StrLen,TempStr,LastDigit,CheckMark,HexcodeIndex
StrLen = Len(HexValue)
LastDigit = Right(HexValue,1)
CheckMark = false
for i = 0 to 15
if Ucase(LastDigit) = HexCode(i) then
CheckMark = true
HexcodeIndex = i
Exit for
end if
next
if CheckMark = false then
WScript.echo "Error From Hex2Bin! The componet of """ & LastDigit &_
""" shouldn't be in the hex format!"
WScript.Quit(1)
end if
if StrLen = 1 then
Hex2Bin = BinaryCode(HexcodeIndex)
else
TempStr = Left(HexValue,StrLen-1)
Hex2Bin = Hex2Bin(TempStr) & BinaryCode(HexcodeIndex)
end if
end Function
Function EnhHex2Bin(byval HexValue)
dim i,StrLen,TempStr,LastDigit,CheckMark,HexcodeIndex
EnhHex2Bin = ""
TempStr = Trim(HexValue)
do while Len(TempStr) > 0
LastDigit = Right(TempStr,1)
CheckMark = false
for i = 0 to 15
if Ucase(LastDigit) = HexCode(i) then
CheckMark = true
HexcodeIndex = i
Exit for
end if
next
if CheckMark = false then
WScript.echo "Warning From EnhHex2Bin! The componet of """ & LastDigit &_
""" shouldn't be in the hex format!"
EnhHex2Bin = -1
exit Function
end if
EnhHex2Bin = BinaryCode(HexcodeIndex) & EnhHex2Bin
TempStr = Left(TempStr,Len(TempStr)-1)
loop
end Function
Function Bin2Hex(byval BinValue)
dim i,StrLen,TempStr,LastDigit,EndMark,CheckMark,BincodeIndex
TempStr = BinValue
'WScript.echo TempStr
StrLen = Len(TempStr)
EndMark = false
if StrLen <= 4 then
EndMark = true
for i = 1 to 4 - StrLen
TempStr = "0" & TempStr
next
else
TempStr = Right(BinValue,4)
end if
CheckMark = false
for i = 0 to 15
if TempStr = BinaryCode(i) then
CheckMark = true
BincodeIndex = i
Exit for
end if
next
if Not CheckMark then
WScript.echo "Error From Bin2Hex! The componet of """ & TempStr &_
""" shouldn't be in the hex format!"
WScript.Quit(1)
end if
if EndMark then
Bin2Hex = HexCode(BincodeIndex)
else
LastDigit = Left(BinValue,StrLen-4)
Bin2Hex = Bin2Hex(LastDigit) & HexCode(BincodeIndex)
end if
end Function
Function Dec2Bin(byval DecValue)
dim tempNum
tempNum = DecValue/2
'WScript.echo tempNum
if tempNum >=0 then
if tempNum = 0 then
Dec2Bin = "0"
elseif tempNum < 1 then
Dec2Bin = "1"
else
if tempNum = Fix(tempNum) then
Dec2Bin = Dec2Bin(Fix(tempNum)) & "0"
elseif tempNum > Fix(tempNum) then
Dec2Bin = Dec2Bin(Fix(tempNum)) & "1"
else
WScript.echo "Error From Dec2Bin! Fix(tempNum) can't be greater than tempNum!"
WScript.Quit(1)
end if
end if
else
WScript.echo "Error From Dec2Bin! TempResult can't be negative!"
WScript.Quit(1)
end if
end Function
Function UTF82Uni(byval BinVal)
dim i,StrLen,TempStr,SegNum,LastStr,LastHeaderLen,QlfLastHdr,UniRangeIndex
UTF82Uni = ""
StrLen = Len(BinVal)
if StrLen <= 48 then
if StrLen <= 8 then
if Len(LTrim0(BinVal)) <= 7 then
UTF82Uni = BinVal
for i = 1 to 8 - Len(UTF82Uni)
UTF82Uni = "0" & UTF82Uni 'Exit 1 of Function
next
else
WScript.echo "Error From UTF82Uni! The input binary number """ & BinVal &_
""" don't accord with UTF8 format(the first bit should be zero)!"
WScript.Quit(1)
end if
else
if (StrLen Mod 8) = 0 then
LastStr = BinVal
'WScript.echo TempStr
SegNum = StrLen/8
for i = 1 to SegNum - 1
TempStr = Right(LastStr,8)
LastStr = Left(LastStr,Len(LastStr)-8)
if Left(TempStr,2) = "10" then
UTF82Uni = Right(TempStr,6) & UTF82Uni
else
WScript.echo "Error From UTF82Uni! The " & i & "th section's data header of input binary number """ &_
BinVal & """ don't accord with UTF8 format(the header is: """ & Left(TempStr,2) & """, while it should be ""10"".)!"
WScript.Quit(1)
end if
next
UniRangeIndex = i
LastHeaderLen = 8 - (UniRangeNoBit(UniRangeIndex) Mod 6)
QlfLastHdr = ""
for i = 1 to LastHeaderLen - 1
QlfLastHdr = QlfLastHdr & "1"
next
QlfLastHdr = QlfLastHdr & "0"
if Left(LastStr,LastHeaderLen) = QlfLastHdr then
UTF82Uni = Right(LastStr,8-LastHeaderLen) & UTF82Uni
UTF82Uni = LTrim0(UTF82Uni) 'Exit 2 of Function
else
WScript.echo "Error From UTF82Uni! The " & UniRangeIndex & "th section's data header of input binary number """ &_
BinVal & """ don't accord with UTF8 format(the header is: """ & Left(LastStr,LastHeaderLen) & """, while it should be """ &_
QlfLastHdr & """.)!"
WScript.Quit(1)
end if
else
WScript.echo "Error From UTF82Uni! The input binary number """ & BinVal &_
""" don't accord with UTF8 format(the No. of bit is " & StrLen &_
". It can not be divided exactly by eight)!"
WScript.Quit(1)
end if
end if
else
WScript.echo "Error From UTF82Uni! The input UTF8 binary number """ & BinVal &_
""" leads to overflow(the length is: " & StrLen & ",greater than 48.)!"
WScript.Quit(1)
end if
end Function
Function Uni2UTF8(byval BinVal)
dim i,OverFlowFlag,StrLen,SegSz,TempStr,dLen
Uni2UTF8 = ""
OverFlowFlag = true
StrLen = Len(LTrim0(BinVal))
for i = 1 to Ubound(UniRangeNoBit)
if StrLen > UniRangeNoBit(i-1) And StrLen <= UniRangeNoBit(i) then
OverFlowFlag = false
SegSz = UniRangeNoBit(i)
Exit for
end if
next
if OverFlowFlag then
WScript.echo "Error From Uni2UTF8! The input binary number """ & BinVal &_
""" leads to overflow!"
WScript.Quit(1)
end if
dLen = SegSz - Len(BinVal)
for i = 1 to dLen
BinVal = "0" & BinVal
next
if SegSz = 7 then
Uni2UTF8 = BinVal
else
TempStr = BinVal
'WScript.echo TempStr
do
Uni2UTF8 = PreFixFill(Right(TempStr,6)) & Uni2UTF8
TempStr = Left(TempStr,Len(TempStr)-6)
loop While Len(TempStr) >= 6
Uni2UTF8 = PreFixFill(TempStr) & Uni2UTF8
end if
end Function
Function LTrim0(byval BinVal)
dim StrLen,TempStr
StrLen = Len(BinVal)
if StrLen = 1 then
LTrim0 = BinVal
else
TempStr = Left(BinVal,1)
if TempStr = "0" then
LTrim0 = LTrim0(Mid(BinVal,2))
elseif TempStr = "1" then
LTrim0 = BinVal
else
WScript.echo "Error From LTrim0! The componet of """ & TempStr &_
""" shouldn't be in the binary format!"
WScript.Quit(1)
end if
end if
end Function
Function PreFixFill(byval BinVal)
dim StrLen
StrLen = Len(BinVal)
if StrLen >=8 then
WScript.echo "Error From PreFixFill! The length of PreFixFilled binary number can not exceed 8!"
WScript.Quit(1)
end if
PreFixFill = "0" & BinVal
do While Len(PreFixFill) < 8
PreFixFill = "1" & PreFixFill
loop
end Function
Function FormatUni(byVal UnicodeVal)
'xx -> %u00xx,while xxx... -> %uxxxx...
dim StrLen
UnicodeVal = Trim(UnicodeVal)
StrLen = Len(UnicodeVal)
if (StrLen Mod 2) <> 0 then
FormatUni = "0" & UnicodeVal
else
FormatUni = UnicodeVal
end if
StrLen = Len(UnicodeVal)
if StrLen < 4 then
FormatUni = "00" & FormatUni
end if
FormatUni = Ucase(FormatUni)
FormatUni = "%u" & FormatUni
end Function
Function FormatUTF8(byval UTF8Val)
dim i,TempStr,StrLen
FormatUTF8 = ""
UTF8Val = Trim(UTF8Val)
StrLen = Len(UTF8Val)
if (StrLen Mod 2) <> 0 Or StrLen <= 0 then
WScript.echo "Error From FormatUTF8! The length of input UTF8 Hex number """ & UTF8Val &_
""" is not qualified(the length is: " & StrLen & " (could be zero or odd number)!"
WScript.Quit(1)
end if
for i = 1 to StrLen/2
TempStr = Mid(UTF8Val,2*i-1,2)
FormatUTF8 = FormatUTF8 & "%" & TempStr
next
end Function
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -