倾情奉献,实现电脑接收和发送中文短信的核心源码!!!!!!!!!!!
ivt 2003-06-20 12:04:18 其实也是一个加密码算法,具体
算法请参照网上相关资料。
'将8bit转为7bit
'E8 32 9B FD 46 97 D9 EC 37
Public Function Encrypt7To8(strSource As String) As String
Dim StrHex As String
Dim strRe As String
Dim StrBinary As String
Dim LngLength As Integer
Dim IntFirst As Integer
Dim newStrBinary As String
Dim newStrHex As String
Dim strResult As String
LngLength = Len(strSource)
StrHex = StringToHex(strSource) '16
strRe = StrRecovent(StrHex) '反转
StrBinary = From16To2(strRe, True) '16 to 2 7bit
IntFirst = 8 - (LngLength Mod 8)
If IntFirst <> 8 Then
newStrBinary = VBA.Right("00000000" & VBA.Left(StrBinary, IntFirst), 8) & VBA.Right(StrBinary, Len(StrBinary) - IntFirst)
Else
newStrBinary = StrBinary
End If
'2 to 16 8bit
newStrHex = From2To16(newStrBinary)
''反转
strResult = StrRecovent(newStrHex)
Encrypt7To8 = strResult
End Function
Public Function Decrypt8To7(strSource As String) As String
Dim intLength As Integer
Dim strRe As String
Dim strResult As String
Dim StrBinary As String
Dim newStrBinary As String
Dim Str8 As String
Dim newStrHex As String
Dim newRe As String
Dim strTemp As String
Dim i As Integer
intLength = Len(strSource) / 2
strRe = StrRecovent(strSource) '反转
StrBinary = From16To2(strRe, False) '16 to 2 8bit
If Len(StrBinary) Mod 7 <> 0 Then
'VBA.Right("0000000" & VBA.Left(StrBinary, (Len(StrBinary) Mod 7)), 7) &
newStrBinary = VBA.Right(StrBinary, (Len(StrBinary) - (Len(StrBinary) Mod 7)))
Else
newStrBinary = StrBinary
End If
Str8 = StrRe7to8(newStrBinary)
'2 to 16
newStrHex = From2To16(Str8)
''反转
newRe = StrRecovent(newStrHex)
''转为字符
For i = 1 To Len(newRe) / 2
strTemp = ChrW(CInt(Val("&H" & VBA.Mid(newRe, (i - 1) * 2 + 1, 2))))
strResult = strResult & strTemp
Next
Decrypt8To7 = strResult
End Function