0 Replies - 759 Views - Last Post: 06 May 2008 - 05:14 PM Rate Topic: -----

#1 lisa0527  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 27-March 08

encryption program

Post icon  Posted 06 May 2008 - 05:14 PM

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

 
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


Is This A Good Question/Topic? 0
  • +

Page 1 of 1