题型:综合题 题类:常考题 难易度:普通
浙江省高中信息技术 加密问题练习
密文 |
1100100 |
11 |
1000 |
1001 |
1110 |
1 |
10011001 |
对应数值 |
100 |
3 |
8 |
9 |
14 |
1 |
153 |
明文 |
* |
C |
H |
I |
N |
A |
* |
Private Sub Command1_Click() ‘密文解密过程
Dim s As String, yw As String
Dim n As Integer,i As Integer,k As Integer,value As Integer
Dim flag As Boolean
s =Text1.Text
yw =“”
flag = True
k = Val(Text4.Text) ‘k为密文的进制
n = Len(s)
value = 0
For i = 1 To n
t = Mid(s, i, 1)
If flag Then
If (t <> “”)Then
If t >=“0” And t <= “9” Then
value =
Else If t >=“A” And t <= “F” Then
value = value*k+Asc(t)-Asc(“A”) + 10
End If
Else
flag = False
If value <=26 Then
yw =
Else
yw = yw + “*”
End If
value = 0
End If
Else
If t >=“0” And t <=“9” Then
value = Asc(t) - Asc(“0”)
flag = True
Else If t >= “A” And t <= “F” Then
value = Asc(t) - Asc(“A”)+ 10
flag = True
End If
End If
Next i
If flag Then
If value < = 26 Then
yw = yw + Chr(Asc(“A”) + value - 1)
Else
yw = yw + “*”
End If
End If
Text2.Text = yw
End Sub
Private Sub Command2_Click() ‘密文加密过程
Dim s As String, yw As String, t As String, key As String
Dim i As Integer, n As Integer, k As Integer, m As Integer
key = “0123456789ABCDEF”
s = Text2.Text
n = Len(s)
yw = “”
k = Val(Text4.Text)
For i = 1 To n
t = Mid(s, i, 1)
m =
If m >= 1 And m <= 26 Then
t =“”
Do While m > 0
t = Mid(key,(m Mod k + 1) , 1) + t
Loop
mw = mw + t + “ ”
End If
Next i
Text3.Text = mw
End Sub
试题篮