Create Your Own Encrypting and Decrypting Program
Posted: Sun Feb 28, 2010 8:06 am
Hey All... This is a tutorial on creating your own encrypting and decrypting application (With save and open function)
Stuff you need to add on form one..:
1 Tab Control:
- Page 1 Title : Encrypt Text
- Button 1 : Encrypt Text
- Show Encrypted Text Button : (Name) = showencrypt
- Textbox1
- Page 2 Title : Decrypt Text
- Button 2 : Decrypt Text
- Show Decrypted Text Button : (Name) = showdecrypt
- Textbox2
- Page 3 Title : Save Encrypted Text File
- Button 3 : Save
- Page 4 Title : Open Encrypted text File
- Button 4 : Open
-----------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------
(So in total... it's:)
Button 1 - Encrypt Text
Button 2 - Decrypt Text
Button 3 - Save Encrypted Text File
Button 4 - Open Encrypted Text File
And Extra 2 Buttons: (Name) = showencrypt & (Name:) = showdecrypt
And you need 2 new forms:
Form2 should be EncryptedText.vb
Form3 should be DecryptedText.vb
And in EncryptedText Form, Add a Text Box, And same in DecryptedText Form
----
Now to the coding part....
----
Code For Button1:
Dim a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z As String
Dim outcome As String
a = "a"
b = "b"
c = "c"
'And so on....
outcome = TextBox1.Text
outcome = Replace(outcome, a, "01")
outcome = Replace(outcome, b, "02")
outcome = Replace(outcome, c, "03")
'... And so on... Tutorial might seem long if i pasted the whole thing so... I'll upload it to some other page..
'And then i'll leave the link at the bottom..
'This part of the code is for changing the capital letter...
outcome = Replace(outcome, "A", "01")
outcome = Replace(outcome, "B", "02")
outcome = Replace(outcome, "C", "03")
MsgBox("Text Decryption Successful")
EncryptedText.TextBox1.Text = outcome
Code For Button2:
Dim a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z As String
Dim outcome As String
a = "a"
b = "b"
c = "c"
'And so on....
outcome = TextBox2.Text
outcome = Replace(outcome, "01", "a")
outcome = Replace(outcome, "02", "b")
outcome = Replace(outcome, "03", "c")
'And so on....
outcome = Replace(outcome, "01", "A")
outcome = Replace(outcome, "02", "B")
outcome = Replace(outcome, "03", "C")
'And so on....
MsgBox("Text Decryption Successful")
DecryptedText.TextBox1.Text = outcome
Code For Button 3:
If EncryptedText.TextBox1.Text = "" Then
MsgBox("You Did Not Encrypt Any Text!")
Else
Dim SaveFile As New SaveFileDialog
SaveFile.FileName = ""
SaveFile.Filter = "Encrypted_Text|*.Encrypted_Text"
SaveFile.Title = "Save"
SaveFile.ShowDialog()
Try
Dim Writer As New System.IO.StreamWriter(SaveFile.FileName)
Writer.Write(EncryptedText.TextBox1.Text)
Writer.Close()
Catch ex As Exception
End Try
Code For Button 4:
Dim Open As New OpenFileDialog()
Dim myStreamReader As System.IO.StreamReader
Open.Filter = "Encrypted_Text|*.Encrypted_Text"
Open.CheckFileExists = True
Open.Title = "OpenFile"
Open.ShowDialog(Me)
Try
Open.OpenFile()
myStreamReader = System.IO.File.OpenText(Open.FileName)
TextBox2.Text = myStreamReader.ReadToEnd()
TabPage2.Select()
TabPage2.Show()
Catch ex As Exception
End Try
Code For "showencrypt":
EncryptedText.Show()
Code For "showdecrypt":
DecryptedText.Show()
---------------------------------------------------------------------
---------------------------------------------------------------------
See Full Tutorial At:
http://tinyurl.com/yfuad9v
Download Full Code At:
http://www.multiupload.com/NAQKYV1PVZ
Stuff you need to add on form one..:
1 Tab Control:
- Page 1 Title : Encrypt Text
- Button 1 : Encrypt Text
- Show Encrypted Text Button : (Name) = showencrypt
- Textbox1
- Page 2 Title : Decrypt Text
- Button 2 : Decrypt Text
- Show Decrypted Text Button : (Name) = showdecrypt
- Textbox2
- Page 3 Title : Save Encrypted Text File
- Button 3 : Save
- Page 4 Title : Open Encrypted text File
- Button 4 : Open
-----------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------
(So in total... it's:)
Button 1 - Encrypt Text
Button 2 - Decrypt Text
Button 3 - Save Encrypted Text File
Button 4 - Open Encrypted Text File
And Extra 2 Buttons: (Name) = showencrypt & (Name:) = showdecrypt
And you need 2 new forms:
Form2 should be EncryptedText.vb
Form3 should be DecryptedText.vb
And in EncryptedText Form, Add a Text Box, And same in DecryptedText Form
----
Now to the coding part....
----
Code For Button1:
Dim a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z As String
Dim outcome As String
a = "a"
b = "b"
c = "c"
'And so on....
outcome = TextBox1.Text
outcome = Replace(outcome, a, "01")
outcome = Replace(outcome, b, "02")
outcome = Replace(outcome, c, "03")
'... And so on... Tutorial might seem long if i pasted the whole thing so... I'll upload it to some other page..
'And then i'll leave the link at the bottom..
'This part of the code is for changing the capital letter...
outcome = Replace(outcome, "A", "01")
outcome = Replace(outcome, "B", "02")
outcome = Replace(outcome, "C", "03")
MsgBox("Text Decryption Successful")
EncryptedText.TextBox1.Text = outcome
Code For Button2:
Dim a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z As String
Dim outcome As String
a = "a"
b = "b"
c = "c"
'And so on....
outcome = TextBox2.Text
outcome = Replace(outcome, "01", "a")
outcome = Replace(outcome, "02", "b")
outcome = Replace(outcome, "03", "c")
'And so on....
outcome = Replace(outcome, "01", "A")
outcome = Replace(outcome, "02", "B")
outcome = Replace(outcome, "03", "C")
'And so on....
MsgBox("Text Decryption Successful")
DecryptedText.TextBox1.Text = outcome
Code For Button 3:
If EncryptedText.TextBox1.Text = "" Then
MsgBox("You Did Not Encrypt Any Text!")
Else
Dim SaveFile As New SaveFileDialog
SaveFile.FileName = ""
SaveFile.Filter = "Encrypted_Text|*.Encrypted_Text"
SaveFile.Title = "Save"
SaveFile.ShowDialog()
Try
Dim Writer As New System.IO.StreamWriter(SaveFile.FileName)
Writer.Write(EncryptedText.TextBox1.Text)
Writer.Close()
Catch ex As Exception
End Try
Code For Button 4:
Dim Open As New OpenFileDialog()
Dim myStreamReader As System.IO.StreamReader
Open.Filter = "Encrypted_Text|*.Encrypted_Text"
Open.CheckFileExists = True
Open.Title = "OpenFile"
Open.ShowDialog(Me)
Try
Open.OpenFile()
myStreamReader = System.IO.File.OpenText(Open.FileName)
TextBox2.Text = myStreamReader.ReadToEnd()
TabPage2.Select()
TabPage2.Show()
Catch ex As Exception
End Try
Code For "showencrypt":
EncryptedText.Show()
Code For "showdecrypt":
DecryptedText.Show()
---------------------------------------------------------------------
---------------------------------------------------------------------
See Full Tutorial At:
http://tinyurl.com/yfuad9v
Download Full Code At:
http://www.multiupload.com/NAQKYV1PVZ