A simple encryption program

Page 1 of 1

1 Replies - 705 Views - Last Post: 07 May 2008 - 08:46 PM Rate Topic: -----

#1 lisa0527  Icon User is offline

  • New D.I.C Head

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

A simple encryption program

Post icon  Posted 07 May 2008 - 05:47 PM

I can not get the encrption to work with this code.
It is suppose to take in a word from the user and encrypt it based on the substitution string in the 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 = 1 To plain.Length  'go through user input string

		 For index2 = 1 To plain.Length  ' go through the cipher alphabet string the length of the input string
			cipher &= cipherAlphabet.Chars(index2) ' append character to string
		 Next
		 cipherTextLabel.Text = cipher ' output new string to label
	  Next
   End Sub ' SubstitutionCipher



Is This A Good Question/Topic? 0
  • +

Replies To: A simple encryption program

#2 Jayman  Icon User is offline

  • Student of Life
  • member icon

Reputation: 418
  • View blog
  • Posts: 9,532
  • Joined: 26-December 05

Re: A simple encryption program

Posted 07 May 2008 - 08:46 PM

Please do not create duplicate topics. You only need to post your question once. Just be patient and someone will answer your question as soon as they are online.

Topic closed.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1