473,406 Members | 2,713 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Substitution Cipher Solver

I am trying to make a substitution cipher solver in vb.net but whenever I try to solve a cipher text using methods other than shift it goes back to the original. This is the code I have so far
Expand|Select|Wrap|Line Numbers
  1. Dim Ctl As Control, nAsc As Int16
  2.         For Each Ctl In Panel2.Controls
  3.             If TypeOf (Ctl) Is TextBox Then
  4.                 nAsc = Asc(Microsoft.VisualBasic.Left(Ctl.Name, 1))
  5.                 If Reverse.Checked = False Then
  6.                     nAsc = nAsc + Shift.Value
  7.                 Else
  8.                     nAsc = 90 - nAsc + 65 + Shift.Value
  9.                 End If
  10.                 If nAsc > 90 Then nAsc = nAsc - 26
  11.                 If nAsc < 65 Then nAsc = nAsc + 26
  12.                 Ctl.Text = Chr(nAsc)
  13.             End If
  14.         Next
  15.         SolutionSubstitution.Text = EncryptionSubstitution.Text
  16.         Dim sourceChar As Char
  17.         For Each Ctl In Panel2.Controls
  18.             If TypeOf (Ctl) Is TextBox Then
  19.                 sourceChar = Microsoft.VisualBasic.Left(Ctl.Name, 1)
  20.                 SolutionSubstitution.Text = SolutionSubstitution.Text.Replace(sourceChar, Chr(Asc(Ctl.Text) + 128))
  21.  
  22.             End If
  23.         Next
  24.         For Each Ctl In Panel2.Controls
  25.             If TypeOf (Ctl) Is TextBox Then
  26.                 sourceChar = Chr(Asc(Microsoft.VisualBasic.Left(Ctl.Name, 1)) + 128)
  27.                 SolutionSubstitution.Text = SolutionSubstitution.Text.Replace(sourceChar, Microsoft.VisualBasic.Left(Ctl.Name, 1))
  28.  
  29.             End If
  30.         Next
  31.  
does anyone have any suggestions

as you can see from the attachments when I press solve it goes back to the original text
Attached Images
File Type: jpg cipherbefore.jpg (36.5 KB, 223 views)
File Type: jpg cipherafter.jpg (37.5 KB, 195 views)
Nov 14 '11 #1
0 1406

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Aaron | last post by:
I am trying to write a Python script file which analyses data in an iterative manner. During each iteration, I wish to utilise the Solver function in Excel to perform some constrained, non-linear...
6
by: Michael Sparks | last post by:
Hi, I suspect this is a bug with AMK's Crypto package from http://www.amk.ca/python/code/crypto , but want to check to see if I'm being dumb before posting a bug report. I'm looking at...
4
by: Carl Harris | last post by:
I am trying to write some code to: 1.Prompt a user for filenames 2.Open the files 3.Convert my plain text into a cipher text array/string bear in mind I am a novice! I have wriiten some code...
9
by: Piotr Turkowski | last post by:
Hi, The code is here: http://free.ud.pl/~piotr/data/vigenere.zip Its my program for decrypting and encrypting text. Shot polish course: szyfrowanie (szyfruj) - encrypting (text i want to code...
3
by: Mr.Doubt | last post by:
I'm trying to run a Excel macro, which uses SOLVER.XLA Add-In, in VB.NET application. When the macro is executed I get the following error message "Solver: An unexpected internal error occured,...
2
by: Julio C. Hernandez Castro | last post by:
Dear all, We have just developped a new block cipher called Raiden, following a Feistel Network structure by means of genetic programming. Our intention now consists on getting as much feedback...
1
by: beetle17 | last post by:
Plaintext: a  n i c e  d a y Key: -3 Ciphertext: X  k f Z b  a X v Cipher will accept commands from the user and perform the operations required by the commands. There are three different...
7
by: Holger Fitschen | last post by:
Hi to all, I want to use the Excel solver in a VB.Net project. The macro Sub Makro1Solver() Application.Run "Solver.xla!Auto_Open" SolverReset Worksheets(1).Select...
4
by: wagn31 | last post by:
i need to use a cipher but I have to used the assigned code in the ciphering i know how to do it, but i am not sure how to add my own dictionary. Here is what i have so far:
3
by: akristensen | last post by:
I am new to this site, so be patient if I do not ask the question correctly. Current Target Platform: Browser: MS IE, script language: Javascript (will use VBScript, but JS is preferred), External...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.