I'm trying to make a program that encrypts a string the user submits. I want to use an encryption technique where the string is advanced 3 letters in the alphabet.
Example: abc
would become def
.
Currently I have a TextBox (TextBox1
) and a Button (Button1
).
My code so far:
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim rawText As String
rawText = TextBox1.Text
Dim letterTxt As String = Chr(Asc(rawText) + 3)
MsgBox(letterTxt)
End Sub
The problem is that when I run it, it only outputs 1 letter.
What did I do wrong?
A Caesar cipher method. Accepts positive and negative shifts and, optionally, a number of alphabet letters.
The latter, to be tested with ASCII tables different than the usual US-ASCII.
It doesn't alter digits (skipped) but you can modify it using the same pattern, if needed.
Use the
Scramble
parameter to select scramble (True) or unscramble (False).Sample test code: