Create a Encryption Program
First, I want to start with the basic fundementals of Cipher, Once you understand the concepts and differences in cipher
you will be able to take what you learn here and the knowledge of cipher and it's history and you can easily begin creating
your own cipher programs
Source Wikipedia
Cipher : In cryptography, a cipher (or cypher) is an algorithm for performing encryption or decryption — a series of well-defined steps that can be followed as a procedure. An alternative, less common term is encipherment.
You may not realize it, but when you were (or are) in school, You may either use the following form of cypher and not realize that what it is
Shift Cypher (Common) Note' Also known as Ceasers Cipher
It is a type of substitution cipher in which each letter in the plaintext is replaced by a letter some fixed number of positions down the alphabet. For example, with a shift of 3, A would be replaced by D, B would become E, and so on. The method is named after Julius Caesar, who used it to communicate with his generals.(source wikipedia) (I learned the name and it's uses in Digital Fortress by: Dan Brown , A must read for Computer Guru's)
The great thing about the Shift Cipher is it can be different every time, but the down side is it is easy to crack, once someone realizes you are using a shift cipher, it's only a matter of time before they deduce the pattern
Code:
Example:
Plain: ABCDEFGHIJKLMNOPQRSTUVWXYZ
Cipher: DEFGHIJKLMNOPQRSTUVWXYZABC
or
Plain: ABCDEFGHIJKLMNOPQRSTUVWXYZ
Cipher: HIJKLMNOPQRSTUVWXYZABCDEFG
or anyway you would like to start
A Commonly Used, Harder to Crack Cipher is the XOR Cipher or XOR encryption (Microsoft developers used this a lot in it's OS' to protect login information)
Source: Wikipedia In cryptography, the simple XOR cipher is a simple encryption algorithm that operates according to the principles
Code:
A 0 = A,
A A = 0,
(B A) A = B 0 = B,
where denotes the exclusive disjunction (XOR) operation. With this logic, a string of text can be encrypted by applying the bitwise XOR operator to every character using a given key. To decrypt the output, merely reapplying the key will remove the cipher.
For example, the string "Wiki" (01010111 01101001 01101011 01101001 in 8-bit ASCII) can be encrypted with the key 11110011 as follows:
01010111 01101001 01101011 01101001
11110011 11110011 11110011 11110011
= 10100100 10011010 10011000 10011010
And conversely, for decryption:
10100100 10011010 10011000 10011010
11110011 11110011 11110011 11110011
= 01010111 01101001 01101011 01101001
The point of mentioning this is to show you there are no limitations, you can make this program as simple or as advanced as you like, use the concept below and use an existing mathematical algorithmic or develop your own.
_________________________________________________
We will be using a simple math algorithm in this tool, the reason I am choosing a math algorithm is simply because you can use any combination of math you like, changing the encryption and making it entirely different from this one, making it even harder to decrypt, even if someone was to happen by this code while browsing.
However you can use the same concept to apply any algorithm, including Caesars (Shift Cypher) and XOR and the hundreds of other algorithm that exist, but the more complex the encryption, the more complex the code(sort of)
O.K Lets Start:
As Always, Lets create a new project, Call it something like Encrypt
On your form add 3 Text Box's and 3 Labels and 2 buttons
[IMG]http://i111.photobucke*****m/albums/n121/golmor/en332.png[/IMG]
Set Two of your textbox's to "Multi Line" and set Scrollbars to Vertical
[IMG]http://i111.photobucke*****m/albums/n121/golmor/marked.jpg[/IMG]
Arrange the TextBox's and Buttons anyway you like (anyway that makes sense and works for you, and your application)
Note: I chose the top to bottom method, maybe best for those just learning this, then once you realize how the software functions, you can move things around to suit your needs
[IMG]http://i111.photobucke*****m/albums/n121/golmor/neat.png[/IMG]
Change the Text of each of your labels and buttons to
Label1 = "Password [8-24 char]"
Label2 = "Text to Decrypt or Encrypt"
Label3 = "Result of Encryption or Decryption"
Or whatever you like, have fun with it, make it your own
Next Change the Text on the buttons to
Button1 = Encrypt
Button2 = Decrypt
Your final product (UI) should look something like this (something like)
[IMG]http://i111.photobucke*****m/albums/n121/golmor/UIfin.png[/IMG]
Now onto the code part
as always I will try and notate everything you may need to know
Code:
' Description:This code is used in making a Encryption Tool
' By: NextGen1 of Mpgh.net
' This code is copyrighted and comes with no warranties.
' This code is intended for demonstration and all rights are granted soley to mpgh.net and it's members
' If you require any further information please contact me at mpgh.net via PM (Get an account if you don't have one)
' Tutorials and apps create by me for mpgh.net will contain the following agreement
' By adding this code in whole or part to any existing or new application you agree to the following terms
' You agree to keep these notes connected with this code.
' You agree to grant credit to it's source (Mpgh.net)
' You agree to keep this note in whole without edit inside of your code
Public Class Form1
Private Sub ButtonX2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonX2.Click
Dim PassInt As Integer
Dim i As Integer
PassInt = GetIntegerFromPassword(TextBoxX1.Text)
TextBoxX3.Text = ""
For i = 1 To Len(TextBoxX2.Text)
'this part decrypts the message by doing the opposite mathamatical equastion as givin in encrypt, in my example
' I used "/ 2 / 3 / 4 / 5 / 6" which divides, so to revers, we must do the opposite and multiply
TextBoxX3.Text = String.Concat(TextBoxX3.Text, Chr(Asc(Mid(TextBoxX2.Text, i, 1)) / PassInt * 2 * 3 * 4 * 5 * 6))
Next i
End Sub
#Region "Transform operations, from Chars to Int and viceversa."
Function GetIntegerFromPassword(ByVal Password As String) As Integer
Dim i As Integer
Dim passedt As Integer
'Passes across the entire String
'Convert Password to integer
For i = 1 To Len(Password)
passedt = passedt + Asc(Mid(Password, i, 1))
Next
'returns the new integer
Return passedt
End Function
#End Region
Private Sub ButtonX1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonX1.Click
Dim PassInt As Integer
Dim i As Integer
' Converts password into Numeric value
PassInt = GetIntegerFromPassword(TextBoxX1.Text)
TextBoxX3.Text = ""
'Converts the message
'You can use any mathimatical forumla you want here
For i = 1 To Len(TextBoxX2.Text)
TextBoxX3.Text = String.Concat(TextBoxX3.Text, CStr(Chr(CInt(Asc(Mid(TextBoxX2.Text, i, 1)) * PassInt / 2 / 3 / 4 / 5 / 6))))
Next i
End Sub
End Class
Results of my test below,
I set password to
"gotohellordie"
The Text to encrypt was
"Hello, How are you? , Meet me at the movies"
The result was
"&599;&;?3<5@;>)55=:53==75:;>85="
Go ahead, have fun with it, try and come up with crazy equations, make it harder to work out. Enjoy it
Screen Shots
[IMG]http://i111.photobucke*****m/albums/n121/golmor/Screensh1ot.png[/IMG]
Virus Scan Eample
Virus Scan Source
Sample Program
Source Code
Note: as always, you may need to edit the sample code to match your controls and their names.