For my computing GCSE course i had to create a keyword cipher and most of my class did it in VB console, so so did it. Little did I know, it was the most difficult project i have had to code. I can't figure out what is wrong with the code!
E.G Its supposed to be AB + AB = BD but it is being outputted as AB + AB = BC
Any help is appreciated
(I have commented on the code if that helps)
Dim final As String 'variables for the function final is declared
Dim offset As String
Dim plain As String
Dim encoded_message() As Integer
Console.WriteLine("Enter text to encrypt: ")
plain = Console.ReadLine.ToUpper 'enter text to encrypt
Console.WriteLine("")
Console.WriteLine("Input encryption keyword:")
offset = Console.ReadLine 'enter offset
offset = Asc(offset)
Console.WriteLine("")
Console.WriteLine("Your Encrypted text is: ")
ReDim Preserve encoded_message(0 To plain.Length - 1)
For stepper As Integer = 0 To plain.Length - 1
encoded_message(stepper) = Asc(plain(stepper)) + offset.Length - 1 'encrypts the text
If encoded_message(stepper) > 90 Then 'if ascii value is above 90
encoded_message(stepper) = (encoded_message(stepper) + offset) - 96 'ascii value decreases by 26
final = Chr(encoded_message(stepper))
ElseIf encoded_message(stepper) = "35" Then 'if ascii value is 35 (space)
encoded_message(stepper) = "0" 'changes ascii value to 0 (blank)
final = Chr(encoded_message(stepper))
ElseIf encoded_message(stepper) >= "48" And encoded_message(stepper) <= "57" Then 'if string inputted contaions a number
encoded_message(stepper) = "0" 'numbers ascii value is changed to 0 (blank)
final = Chr(encoded_message(stepper)) 'output encrypted text
Else
final = Chr(encoded_message(stepper)) 'output encrypted text
End If
Console.Write(Chr(encoded_message(stepper))) 'output encrypted text
Next
Console.ReadLine()