I need to create a project that will encrypt and decrypt the alphabet. if there is a space or unknown character the program should just leave it like that or blank .
"a" = 0
"b" = 1
"c"= 2 ...
"z" = 25
if the sum is greater than 26 then continues to
"a" = 26
"b" = 27
"c" = 28
I have tried to do it but it's not working my teacher said that we could use the Mod i don't know how to use
Please help
Option Explicit On
Option Strict On
Option Infer Off
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ChangeButton.Click
Dim plainlist As String
Dim key As String
Dim firstnumb As String
Dim secnum As String
Dim encryptedms As String
Dim newvalue As Integer
Dim alphavalue2 As Integer
Dim alphabet As String = "abcdefghijklmnopqrstuvwxyz"
Dim alphaValue As Integer
Dim counter As Integer = 0
Dim counter2 As Integer = 0
plainlist = plainTextBox.Text
key = keyTextBox.Text
counter = 0
counter2 = 0
Do While counter < plainlist.Length
firstnumb = plainlist.Substring(counter, 1)
alphaValue = alphabet.IndexOf(firstnumb)
MessageBox.Show(CStr(alphaValue))
secnum = key.Substring(counter2, 1)
alphavalue2 = alphabet.IndexOf(secnum)
MessageBox.Show(CStr(alphavalue2))
newvalue = alphabet.IndexOf(firstnumb) + alphabet.IndexOf(secnum)
MessageBox.Show(CStr(newvalue))
If alphaValue = -1 Then
encryptedms = firstnumb
End If
If alphaValue > 25 Then
alphaValue = alphaValue - 26
End If
If alphaValue = -1 Then
encryptedms = plainlist.Substring(counter, 1)
Else
encryptedms = alphabet.Substring(newvalue, 1)
End If
counter = counter + 1
counter2 = counter2 + 1
encryptLabel.Text = encryptLabel.Text & encryptedms
Loop
Bookmarks