Thread: ROT Decryptor
View Single Post
Old Jul 8th, 2005, 8:12 PM   #2
Rory
Expert Programmer
 
Rory's Avatar
 
Join Date: Jan 2005
Location: London
Posts: 542
Rep Power: 4 Rory is on a distinguished road
Send a message via MSN to Rory
Your adding 13 (byte) to a character which should work as they are actually the same thing but no in VB's universe.
Chr(Asc(Encrypted.Substring(Index, 1)) + 13)

For some reason VB's so Unicodified (Grrr! English IS the only language in the world). This works though:

    Dim ROTIndex As Byte
    Dim Buffer As Char()

    Sub Main()
        Console.Write("Rotation index: ")
        ROTIndex = Console.ReadLine()

        Console.Write("Encrypted text: ")
        Buffer = Console.ReadLine()

        For Index As Integer = Buffer.GetLowerBound(0) To Buffer.GetUpperBound(0)
            Buffer(Index) = Chr(Asc(Buffer(Index)) + ROTIndex)
        Next

        Console.WriteLine("Decrypted Text: " & Buffer)

        Console.ReadLine()
    End Sub
Rory is offline   Reply With Quote