I have tried to make a program to decrypt simple ROT decryptions which is where if it's like ROT 4 you move each letter 4 spaces down, so A becomes E, W becomes Z and so on. Here is my code:
Dim ROTIndex As Integer
Dim Encrypted As String
Dim Decrypted() As String = ""
Sub Main()
Console.WriteLine("Rotation index: ")
ROTIndex = Console.ReadLine()
Console.WriteLine("Encrypted text: ")
Encrypted = Console.ReadLine()
For Index As Integer = 0 To Encrypted.Length
Decrypted = Decrypted & Chr(Asc(Encrypted.Substring(Index, 1) + 13))
Next
Console.WriteLine("Decrypted Text: " & Decrypted)
End Sub
It looks all well and good but when I try to run it I get a bug saying "Invalid cast exception -> cast from string "h" to type 'Double' is not valid" and it says it's occurring on the line that says this:
Decrypted = Decrypted & Chr(Asc(Encrypted.Substring(Index, 1) + 13))
Does anybody know why it may be doing this?