473,811 Members | 4,039 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Substitution Cipher Solver

6 New Member
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, 230 views)
File Type: jpg cipherafter.jpg (37.5 KB, 198 views)
Nov 14 '11 #1
0 1422

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

Similar topics

1
7045
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 fitting to the data. I have a VBA macro which runs the Solver, and am using self.xlapp = win32com.client.dynamic.Dispatch("Excel.Application") .. .. .. self.xlapp.run(macro)
6
6587
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 using this library and to familiarise myself writing small tests with each of the ciphers. When I hit Crypto.Cipher.ARC4 I've
4
8035
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 already which completes takes 1 and 2 but haven't got a clue with the conversion (task 3)
9
3728
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 -> (*(^%&^GHJBBVvkek) odszyfrowanie (deszyfrowanie) - decrypting ( *^BNHJ*&% - > secret text) obsluga plikow - using files
3
6996
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, or available memeory was exhausted" Any suggestions whats causing this error and how to debug it??? Also, I get the following exception message when executing all the
2
7299
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 as possible from users, so we encourage you to test the algorithm and send us your opinion. We would also like to receive enhancements and new versions of the algorithm, developed in other source languages and platforms. Our idea on developing...
1
7735
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 commands. Key command starts with "K1:"followed by a string as the key. Encryption command starts with "E1:" followed by the plaintext. Decryption command starts with "D1:" followed by the ciphertext to be decrypted. After the user inputs an encryption...
7
14414
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 Worksheets(1).Range("B9").Select
4
10219
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
7390
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 apps: MS Excel What I need to do: From a web page using javascript, I open a new Excel application and sheet, populate some information into it. After it is populated with some information, I need to run the "Solver..." option on the data in the...
0
9724
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9604
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10394
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10127
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9201
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7665
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5552
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4336
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3863
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.