Welcome to Dream.In.Code
Getting VB.NET Help is Easy!

Join 86,243 VB.NET Programmers. There are 2,248 online right now! Ask your question and get quick answers from Dream.In.Code experts. Join the #1 programming help community on the internet! Registration is fast and FREE... Join Now!

Chat LIVE With a VB.NET Expert
Powered by LivePerson.com

Register to Make This Box Go Away!

encryption program

 
Reply to this topicStart new topic

encryption program, homework

lisa0527
post 6 May, 2008 - 05:14 PM
Post #1


New D.I.C Head

*
Joined: 27 Mar, 2008
Posts: 3



I have to create a program that takes in a word from a user and encrypts it. The function is call SubstitutionCipher. (Am I still working on the TranspositionCipher so don't worry about looking at that function.

I am always receiving the same 'bb' output and not sure why.

Can you please take a look at the code.
Thanks

CODE

Public Class EncryptionForm

   ' using the substitution cipher
   Private Sub SubstitutionCipher()

      ' normal alphabet String
      Dim normalAlphabet As String = _
         "abcdefghijklmnopqrstuvwxyz .!?,"

      ' substitution alphabet String
      Dim cipherAlphabet As String = _
         "cdefg.hijk!lmn opqr?stuv,wxyzab"

      Dim index1 As Integer ' index variable for For...Next loop
      Dim index2 As Integer ' inner index variable
      Dim plain As String = plainTextBox.Text ' String entered by the user
      Dim cipher As String ' encrypted String

      cipherTextLabel.Text = "" ' clear output TextBox
      plain = plain.ToLower() ' make characters lowercase

      For index1 = 0 To 30 ' go through string for normal alphabet
         plain = normalAlphabet.Chars(index1)

         For index2 = 0 To 30 ' go through string for cipher alphabet
            cipher = cipherAlphabet.Chars(index2) ' new string = new character
            cipher &= cipherAlphabet(index2) ' append character to string
         Next
         cipherTextLabel.Text = cipher ' output new string to label
      Next
   End Sub ' SubstitutionCipher

   ' using the transposition cipher
   Private Sub TranspositionCipher()

      Dim counter As Integer = 0 'loop counter variable
      Dim input As String = plainTextBox.Text ' input word by user
      Dim output As String ' changed word

      Do While counter <= 30
         counter = +2

      Loop

   End Sub ' TranspositionCipher

   Private Sub encryptButton_Click(ByVal sender As System.Object, _
   ByVal e As System.EventArgs) Handles encryptButton.Click

      If substitutionRadioButton.Checked = True Then 'if substitution radio button checked
         SubstitutionCipher() ' goto function
      Else
         TranspositionCipher() ' if transposition radio button checked goto function
      End If
   End Sub
End Class ' EncryptionForm
User is offlineProfile CardPM
Go to the top of the page
+Quote Post


Fast ReplyReply to this topicStart new topic
Time is now: 5/16/08 08:24AM

Live VB.NET Help!

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month