为什么这个解密不起作用?

时间:2015-11-13 11:50:00

标签: .net vb.net encryption

星空中出现的代码不起作用。我试图解密一个加密的表格,但却失败了。

    Dim SmpleFile As String ' the encrypted text
    Dim tf As String = ""
    Dim plaintext As String = ""
    Dim Factor As Integer = Val(lblOffsetFac.Text)
    Dim cyphertextch As Integer

    SmpleFile = lblEncdText.Text

    For Each ch As Char In SmpleFile
        'This means the spaces wont change
        If ch = " " Then
            cyphertextch = 32
        Else 'If the character doesnt = " "
            'This means that if the number is less
            'than 33, 94 will be added to make the
            'character convertable and correct.

            cyphertextch = Asc(ch)
            cyphertextch = cyphertextch + Factor

            If cyphertextch < 33 Then
                cyphertextch = cyphertextch + 94

            End If

        End If
        **plaintext += Chr(cyphertextch)**

    Next
    'This displays the newly decyped textfile which is the same as sample.txt
    lblDecdText.Text = plaintext
    lblDecdText.Visible = True
End Sub

我被告知我不能大声喊叫,但如果可以的话,这将是所有人都在大都会表达我的绝望

1 个答案:

答案 0 :(得分:1)

您应该使用plaintext = plaintext & Chr(cyphertextch)& is an operator in VB.NET to perform string concatenation。或者,您也可以使用StringBuilder.append