,因附件不支持压缩文件,故在后面加了一个txt的扩展名。
源码如下:
Option Explicit
Private Sub Command1_Click()
Text1.Text = ROR("44414D4E", 1)
Text2.Text = ROR("44414D4E", 2)
Text3.Text = ROR("2220A6A7", 1)
End Sub
Public Function ROR(nSource As String, N As Integer) As String 'nSource为16进制字符串形式,N为循环右移次数
'目的操作数右移,每移位一次,其最低位移入最高位,同时最低位也移入进位标志CF????????????????
Dim Tmp, TmpLeft, TmpRight, Result As String
Tmp = HexToBin(nSource)
If N = 1 Then
TmpLeft = Left(Tmp, 1)
TmpRight = Right(Tmp, Len(Tmp) - 1)
End If
TmpLeft = Left(Tmp, Len(Tmp) - N)
TmpRight = Right(Tmp, N)
Result = TmpRight & TmpLeft
ROR = BintoHex(Result)
End Function
Function HexToBin(HexStr As String) As String '任意长度的16进制整数转为2进制
Dim temp, BinStr, Bin As String
Dim i As Integer
HexStr = UCase(HexStr) '将小写转换成大写
For i = 1 To Len(HexStr)
Select Case Mid(HexStr, i, 1)
Case "0": BinStr = "0000"
Case "1": BinStr = "0001"
Case "2": BinStr = "0010"
Case "3": BinStr = "0011"
Case "4": BinStr = "0100"
Case "5": BinStr = "0101"
Case "6": BinStr = "0110"
Case "7": BinStr = "0111"
Case "8": BinStr = "1000"
Case "9": BinStr = "1001"
Case "A": BinStr = "1010"
Case "B": BinStr = "1011"
Case "C": BinStr = "1100"
Case "D": BinStr = "1101"
Case "E": BinStr = "1110"
Case "F": BinStr = "1111"
End Select
temp = temp & BinStr
Next i
While Left(temp, 1) = "0"
temp = Right(temp, Len(temp) - 1)
Wend
HexToBin = Trim(temp)
End Function
Function BintoHex(BinStr As String) As String '任意长度的2进制整数转为16进制
Dim H As String
Dim i As Integer
If Len(BinStr) Mod 4 <> 0 Then BinStr = String(4 - (Len(BinStr) Mod 4), "0") & BinStr
For i = 1 To Len(BinStr) Step 4
Select Case Mid(BinStr, i, 4)
Case "0000": H = H & "0"
Case "0001": H = H & "1"
Case "0010": H = H & "2"
Case "0011": H = H & "3"
Case "0100": H = H & "4"
Case "0101": H = H & "5"
Case "0110": H = H & "6"
Case "0111": H = H & "7"
Case "1000": H = H & "8"
Case "1001": H = H & "9"
Case "1010": H = H & "A"
Case "1011": H = H & "B"
Case "1100": H = H & "C"
Case "1101": H = H & "D"
Case "1110": H = H & "E"
Case "1111": H = H & "F"
End Select
Next i
BintoHex = H
End Function
Private Sub Command1_Click()
Text1.Text = MYROR("44414D4E", 1)
Text2.Text = MYROR("44414D4E", 2)
Text3.Text = MYROR("2220A6A7", 1)
End Sub
Function MYROR(nSource As String, N As Integer) As String
Dim i As Long, x As String
x = nSource
For i = 1 To N
x = ROR(x, 1)
Next
MYROR = x
End Function
Public Function ROR(nSource As String, N As Integer) As String 'nSource为16进制字符串形式,N为循环右移次数
'目的操作数右移,每移位一次,其最低位移入最高位,同时最低位也移入进位标志CF????????????????
Dim Tmp, TmpLeft, TmpRight, Result As String
Tmp = HexToBin(nSource)
If N = 1 Then
TmpLeft = Left(Tmp, 1)
TmpRight = Right(Tmp, Len(Tmp) - 1)
else
TmpLeft = Left(Tmp, Len(Tmp) - N)
TmpRight = Right(Tmp, N)
End If
Result = TmpRight & TmpLeft
ROR = BintoHex(Result)
End Function