Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27379

VS 2010 Decrypting textfile split with ROT 13

$
0
0
So I am trying to make a login system that decrypts the password as they attempt to login using ROT 13.

Code:

  Using srUser As New System.IO.StreamReader("Details\userdata.txt") 'Sets streamreader to username password textfile
            While Not srUser.EndOfStream 'Loops while file is being read
                Dim userdetails() As String = srUser.ReadLine.Split(",")

                Dim decrypt2 As String = userdetails(1) 'Assigns second split to the string

                For t = 1 To Len(decrypt2.ToString) 'The len function is equal to the amount of characters in a string

                    Mid(decrypt2, t, 1) = Chr(Asc(Mid(decrypt2, t, 1)) - 13) 'Mid function returns characters from a string

                Next t 'Loops through the next line
                If txtUsername.Text = userdetails(0).ToString And txtPassword.Text = decrypt2 Then 'If line matches both entered username and password
                    MsgBox("Welcome User: " & userdetails(0).ToString) 'Correct, displays messagebox with there username
                    srUser.Close() 'closes the file
                    Exit Sub 'exits sub
                End If
            End While 'Stops the loop
            MsgBox("Invalid Username or Password") 'If textfile doesn't contain entered username or password, error.
            srUser.Close() 'Closes the file
        End Using

    End Sub

Some things are decrypted
Such as 123 from ?@> or something like that
but when I goto decrypt names such as "smoky" and "tom" it doesn't want to work

I have encrypted using this algorithm
Code:

     
        amountrotate = 13
        encrypt = TextBox1.Text

        Dim t As Integer = 1

        For t = 1 To Len(encrypt) 'The len function is equal to the amount of characters in a string

            Mid(encrypt, t, 1) = Chr(Asc(Mid(encrypt.ToString, t, 1)) + 13) 'Mid function returns characters from a string

        Next t

Thanks for your time

Viewing all articles
Browse latest Browse all 27379

Trending Articles