Enigma Encryption Example
Here is the concept behind this representation of the Enigma Machine: The program uses virtual "wheels" that contain all of the printable characters on the keyboard. Think of the first wheel as the keyboard you are typing on. All of the wheels contain the same characters, but in a random, non-repeating order. Each time a character is pressed, the location of that character on the one wheel is used to as the index to lift the character off of the next wheel. Then the new character is searched for in the next wheel, and the pattern repeats itself across each wheel. The character lifted off of the final wheel is the output. This step is repeated for each character in the message. Decryption simply sends the message backwards through a similar, but reversed process. What really makes this encryption effective is that like the real life machine, the wheels rotate either to the left or right after each character. So the relationship between each character shifts constantly. As a result, even repeating characters such as "AAAAAAAAAAAAA" are represented with garbage such as "@n~WPnHv(.)z#" Another great part about an encryption scheme like this is its flexibility. You can add more wheels, more characters per wheel, change the order of the wheels, the directions the wheels spin, and change the starting position of each wheel. So, unless somone can figure out: 1) How many wheels are being used... 2) How many characters are on each wheel... 3) The order of the wheels... 4) The direction they spin... 5) The initial position of each wheel... 6) The order of the characters on each wheel... It would be virtually impossible to look at the encrypted characters and determine their relationship to one another. There are so many possibilities and combinations of the above criteria, it would have to be solved through brute force. I am no mathmatician, so if anyone can tell me the possible combinations, I would appreciate it. When the Germans used this machine, it baffled the Allies, who frantically tried to break it with no success. It wasnt until a German U-Boat was forced to surface in a naval battle and was captured that the Allies got a huge break. An Enigma machine was captured along with a code book that showed the information needed to decrypt the messages. The U-Boat was scuttled and the crew was kept in a top secret location. The U-Boat was simply considered lost during battle and Germans continued the war not knowing the truth. When the war in the Atlantic turned for the worse, the Germans, who believed their code to be unbreakable, believed that there were spies in their top level officials. They never considered that the code was being decrypted through a captured machine, so as a result, they set up elaborate networks to try and find these "spies". Paranoia being what it was, many loyal German officers were tortured and murdered for treason, even though they had commited no such offense. This code is by no means complete. I will try and enhance its speed and toughen its encryption even further. Ill also try and build a better sample app with more features. If you find a problem or have a suggestion, I would love to hear it. This program has now been updated to reflect many of the suggestions posted here. Thanks for some great feedback and keep coding! =)
ملخص الذكاء الاصطناعي: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.
Upload
<p><font face="Verdana" size="2"><strong>Sending Data</strong></font></p>
<p><font face="Verdana" size="2">First, let's try to understand how we send the
data from page to page. The data is sent using two possible methods with HTTP
(Hypertext Transfer Protocol). You can pass data with HTML tags using the FORM
"POST or GET" methods, or with hyperlinks.</font></p>
<blockquote>
<ol>
<li><font face="Verdana" size="2">If you use the FORM method you basically
tell the browser to wrap up a bunch of input box information within the
form tags on your web page and post everything to <a href="http://www.aspalliance.com/glenncook/cookiecode.asp"><font color="mediumblue" face>a
script</font></a> that can accept and translate the information sent.</font>
<li><font face="Verdana" size="2">If you are sending data using a hyperlink,
you have to customize the hyperlink to declare and define a string
variable. It's easy! All you do is point your hyperlink to the URL, you
add a question mark, and you add your variable. Test this example: <a href="http://www.aspalliance.com/glenncook/vbsample.asp?HomerVariable=HelloMyNameIsPuka"><font color="mediumblue" face>http://www.aspalliance.com/glenncook/vbsample.asp?HomerVariable=HelloMyNameIsPuka</font></a></font>
<li><font face="Verdana" size="2">For another example go to <a href="http://www.nasdaq.com"><font color="mediumblue" face>NASDAQ.com
</font></a>and look at the HTML source for that page and find the form
post code. See how it names the input fields? Now, go back to the actual
page and submit a ticker symbol like AMZN (Amazon.com- my pick of the
month) and click "Get Flash Quotes." If you look at the Url in
your browser, you'll notice a bunch of variables that you sent to the
page. If you only put in one ticker symbol, that will be the only one you
see listed- the rest of the variables will be empty.<br>
</font></li>
</ol>
</blockquote>
<p><font face="Verdana" size="2"><strong>Requesting the Data<br>
<br>
</strong>With ASP, all you have to do to get your data is to "Request"
it. When you set up the asp script page to receive the data, you usually want to
use a "If Then" or a "Select Case" statement at the top of
your page. But before I get into the semantics of these statements let's just
get the data!</font></p>
<p><font face="Verdana" size="2">If a form is sending the data you use this asp
code to grab each input field's data:</font>
<ul>
<li><font color="#008000" face="Courier New" size="2"><% Request.Form("NameOfField1")%></font></li>
</ul>
<p><font face="Verdana" size="2">Or you can print the field's data to a page
using this code anywhere in your asp script page:</font>
<ul>
<li><font face="Courier New"><font size="2"><</font><font color="#008000" size="2">%=Request.Form("NameOfField1")%></font></font><font face="Verdana" size="2">
(Notice that little "=" sign? Yep, that's all you need to know to
print asp data into your HTML code.)</font></li>
</ul>
<p><font size="2" face="Verdana">If the data is being sent by a hyperlink use
this code to grab the variable:</font>
<ul>
<li><font color="#008000" face="Courier New" size="2"><%
Request.Querystring("NameOfVariable") %></font></li>
</ul>
<p><font size="2" face="Verdana">Likewise, you can print the data anywhere in
the page using:</font>
<ul>
<li><font color="#008000" face="Courier New" size="2"><%=Request.QueryString("NameOfVariable")%></font></li>
</ul>
<p><font face="Verdana" size="2"><strong>Ok, so you know how to get the data,
now what do you do with it?</strong></font></p>
<p><font face="Verdana" size="2">Well, the sky is the limit! Manipulating this
data is how you make smart webpages. You can use the data to write cookies,
connect to databases and extract certain recordsets, or you can control the HTML
code that prints to the user's screen, etc. In this tutorial though I will focus
on extracting the user's information early in the visit to the site, and how you
can extract that data anytime during the session-not unlike a shopping cart
tracks the contents of your order.</font></p>
<p><font face="Verdana" size="2">ASP lets you create some global variables at
the beginning of the user session in the Global.asa file. When you hit an ASP
site the first thing ASP does is look to the Global.asa file to get any
important information it needs to know for that user session. A session begins
when a user first visits the site after the OnStart event fires in the
Global.asa file. The Global.asa file is like the config.sys file in DOS when you
first turn on your computer. It configures the user session, and lets you free
up memory space for any variables you might want. Each user session lasts as
long as the person is visiting the site. The session ends when the user closes
the browser, after an amount of time set by the system administrator, or by code
telling ASP to end the session. What you want to do with the Global.asa is free
up some memory space by declaring a few (or many) variables. As long as the
session exists, the memory space for these variables will also exist. Logically,
anytime you want to know what information is contained within these session
variables you can extract it. Just as easily you can write information to these
variables anytime. (See where I'm going with this?)</font></p>
<p><font face="Verdana" size="2">In your Global.asa file you&rsquo;ll find
the Session_OnStart event and this is where you want to create your variables.</font></p>
<div align="center">
<center>
<table border="1" width="100%">
<tbody>
<tr>
<td vAlign="top" width="50%"><font color="#008000" size="1" face="Courier New"><SCRIPT
LANGUAGE=VBScript RUNAT=Server><br>
Sub Application_OnStart<br>
End Sub<br>
Sub Application_OnEnd<br>
End Sub</font></td>
<td vAlign="top" width="50%"><font color="#ff0000" face="Arial" size="2">Simplified:
This code executes the very first time a user hits the weblication and
ends some time after the last person leaves.</font></td>
</tr>
<tr>
<td vAlign="top"><font color="#008000" size="1" face="Courier New">Sub
Session_OnStart<br>
Session("Variable1") = 0<br>
Session("Variable2") = 0<br>
Session("Variable3") = 0<br>
End Sub</font></td>
<td vAlign="top"><font color="#ff0000" face="Arial" size="2">This code
is what you're concerned with. When a user hits your site, ASP goes
right to the Global.asa and fires this event to start a session. We've
also declared a few variables that we will use while the user is at
the site. These variables end when a user ends the session.</font></td>
</tr>
<tr>
<td vAlign="top"><font color="#008000" face="Courier New" size="1">Sub
Session_OnEnd<br>
End Sub<br>
</SCRIPT></font></td>
<td vAlign="top"><font color="#ff0000" face="Arial" size="2">This code
fires at the end of a user session.</font></td>
</tr>
</tbody>
</table>
</center>
</div>
<p><font face="Verdana" size="2">This is really all there is to it. Now you can
use the information you extract from the user and write it to one of these
variables. I would use this code at the beginning of the asp script that
receives the information sent by a form. All I&rsquo;m doing is writing the
submitted data to the session variables, which I can extract anytime during the
session.</font></p>
<p><font color="#008000" face="Courier New" size="2"><%<br>
dim variable1<br>
dim variable2<br>
dim variable3</font></p>
<p><font color="#008000" face="Courier New" size="2">variable1 = Request.Form("Field1")<br>
variable2 = Request.Form("Field2")<br>
variable3 = Request.Form("Field3")</font></p>
<p><font color="#008000" face="Courier New" size="2">Session("Variable1")
= variable1<br>
Session("Variable2") = variable2<br>
Session("Variable3") = variable3<br>
%></font></p>
<p><font face="Verdana"><font size="2">Now you can print that variable to a page
anytime by using the code, </font><font color="#008000" size="2"><%=Session("Variable1")%></font><font size="2">.
You can also extract that information to use in an SQL statement:</font></font><font face="Arial" size="2"><br>
</font><font face="Courier New"><font color="#008000" size="2"><%<br>
dim MartinPrince<br>
MartinPrince = Session("Variable1")<img align="right" src="http://www.aspalliance.com/glenncook/images/bumhacker.jpg" width="114" height="128"><br>
%><br>
</font><font color="#007f00" size="2"><% "SELECT * FROM Employees Where
FirstName = '" & MartinPrince & "'" %></font></font></p>