3C3F3E39383B3A353437
 a b c d e f g h i j
我想用vb 把他写成解密的。   比如在text中输入3C3F3E39383B   输出的结果为abcdef  改怎么写?

解决方案 »

  1.   

    自定义解密呀,提供个简单的思路,用二维数组保存对应关系,如s(0,0)对应(3C,a),解密时取字符串一次取2位,从数组里翻译出来
      

  2.   


    Private Sub Command1_Click()
        Text1.Text = "3C3F3E39383B"
        Dim j As Integer
        For i = 1 To Len(Text1.Text) / 2
            strTemp = Mid(Text1.Text, (i - 1) * 2 + 1, 2)
            For j = 1 To colDes.Count
                If UCase(strTemp) = colSource.Item(j) Then
                    Text2.Text = Text2.Text & colDes.Item(j)
                End If
            Next
        Next
    End SubPrivate Sub Form_Load()
        Dim strSource, strDes As String
        Dim strTemp As String
        strSource = "3C3F3E39383B3A353437"
        strDes = "abcdefghij"
        
        Dim i As Integer
        For i = 0 To Len(strSource) / 2 - 1
            strTemp = Mid(strSource, i * 2 + 1, 2)        colSource.Add CVar(strTemp)
        Next
        
        For i = 0 To Len(strDes) - 1
            strTemp = Mid(strDes, i + 1, 1)
            colDes.Add CVar(strTemp)
        Next
        Text1.Text = ""
        Text2.Text = ""
    End Sub
      

  3.   


    Private Sub Command1_Click()
        Text1.Text = "3C3F3E39383B"
        Dim j As Integer
        For i = 1 To Len(Text1.Text) / 2
            strTemp = Mid(Text1.Text, (i - 1) * 2 + 1, 2)
            For j = 1 To colDes.Count
                If UCase(strTemp) = UCase(CStr(colSource.Item(j))) Then
                    Text2.Text = Text2.Text & colDes.Item(j)
                End If
            Next
        Next
    End SubPrivate Sub Form_Load()
        Dim strSource, strDes As String
        Dim strTemp As String
        strSource = "3C3F3E39383B3A353437"
        strDes = "abcdefghij"
        
        Dim i As Integer
        For i = 0 To Len(strSource) / 2 - 1
            strTemp = Mid(strSource, i * 2 + 1, 2)        colSource.Add CVar(strTemp)
        Next
        
        For i = 0 To Len(strDes) - 1
            strTemp = Mid(strDes, i + 1, 1)
            colDes.Add CVar(strTemp) '这里数据类型也可以不转化
        Next
        Text1.Text = ""
        Text2.Text = ""
    End Sub
      

  4.   

    xrongzhen 大哥。提示要求对象。colSource.Add CVar(strTemp)
      

  5.   

    若仅仅是这样的一串字符处理,可以这样:
    'str1="3C3F3E39383B3A353437"
    'str2="abcdefghij"
    'str3="3Ca3Fb3Ec39d38e3Bf3Ag35h34i37j"'定义一个函数
    public function decrypt(str as string)
        strkey="3Ca3Fb3Ec39d38e3Bf3Ag35h34i37j"
        dim key(1 to 10) as string
        for i=1 to 10 step 3
           key(i)=mid(strkey,i,3)
        next i
        if len(str)=0 then
           decrypt=""
           exit function
        end if
        decrypt=""
        for i=1 to len(trim(str)) step 2
           for j=1 to 10
              if mid(key(j),1,2)=mid(trim(str),i,2) then
                  decrypt=decrypt & right(key(j),1)
                  exit for
              end if
           next j
           if j>10 then
               decrypt=decrypt & "X"
           end if
        next i
    end function'程序中使用自定义函数
    text2.text=decrypt(text1.text)
      

  6.   

    '楼上的代码有问题  用下面的
    '定义一个函数
    Public Function decrypt(str As String)
    Dim i, j As Long
          strkey = "3Ca3Fb3Ec39d38e3Bf3Ag35h34i37j"
        Dim key(9) As String
        For i = 1 To 30 Step 3
          key(j) = Mid(strkey, i, 3)
          j = j + 1
        Next i
        If Len(str) = 0 Then
          decrypt = ""
          Exit Function
        End If
        decrypt = ""
        For i = 1 To Len(Trim(str)) Step 2
          For j = 0 To 9
              If Mid(key(j), 1, 2) = Mid(Trim(str), i, 2) Then
                  decrypt = decrypt & Right(key(j), 1)
                  Exit For
              End If
          Next j
          If j > 10 Then
              decrypt = decrypt & "X"
          End If
        Next i
        
        
    End FunctionPrivate Sub Command1_Click()
    '程序中使用自定义函数
    Text2.Text = decrypt(Text1.Text)End Sub
      

  7.   

    chinayuppie  这位大哥的没问题啊我用他的搞定了