当前位置: 高中信息技术 / 综合题
  • 1. (2021·湖州模拟) 某数据加密算法如下所示:在文本框Text1中随机生成8位小写字母,首先将每一个字母转换成8位二进制数,如“a”转换成8位二进制数为“01100001”,然后将8位二进制数循环左移两位,如“01100001”左移两位的结果是“10000101”,然后将左移后的结果依次显示在列表框List1中,最后将所有的二进制数转换成十六进制显示在文本框Text2中,文本框Text2中显示的结果即是加密后的结果,程序运行的部分界面如图所示:

    1. (1) 明文“z”对应的密文是 。
    2. (2) 实现上述功能的VB程序如下所示,请在划线处填入合适的代码。

      Dim s As String, ch As String

      Dim i As Integer, data As Integer

      Const n = 8

      Private Sub Form_Load()

          For i = 1 To n

              '随机生成n位小写字母显示在文本框Text1中

          Next i

      End Sub

      Private Sub Command1_Click()

          Dim count As Integer, j As Integer, m As Integer

          Dim a(1 To 64) As Integer

          Dim b(1 To 64) As Integer

          Const sj = "0123456789ABCDEF"

          s = Text1.Text: count = 0

          For i = 1 To Len(s)

              data = Asc(Mid(s, i, 1))

              Do While count <> n

                 

                  data = data \ 2

                  count = count + 1

              Loop

              count = 0

          Next i

          tmp = 0

          For m = 1 To n * n

              i = (m - 1) \ n + 1: j = (m - 1) Mod n + 1

              b((i - 1) * n + j) =

              s1 = s1 + Str(b((i - 1) * n + j))

              If j Mod n = 0 Then List1.AddItem s1: s1 = ""

                  tmp =

                  If j = 4 Or j = 8 Then

                      s2 = s2 + Mid(sj, tmp + 1, 1): tmp = 0

              End If

          Next m

          Text2.Text = s2

      End Sub

微信扫码预览、分享更方便