Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Xolara's Tutorials
#5
A3 - Encrypter

1 Form
2 Textboxes 1 of them is multilined and the other is for password
2 buttons Encrypt and Decrypt

Code:
Public Class Form1
    Dim DES As New System.Security.Cryptography.TripleDESCryptoServiceProvider
    Dim Hash As New System.Security.Cryptography.MD5CryptoServiceProvider
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Try
            DES.Key = Hash.ComputeHash(System.Text.ASCIIEncoding.ASCII.GetBytes(TextBox1.Text))
            DES.Mode = Security.Cryptography.CipherMode.ECB
            Dim DESEncrypter As System.Security.Cryptography.ICryptoTransform = DES.CreateEncryptor
            Dim Buffer As Byte() = System.Text.ASCIIEncoding.ASCII.GetBytes(TextBox2.Text)
            TextBox2.Text = Convert.ToBase64String(DESEncrypter.TransformFinalBlock(Buffer, 0, Buffer.Length))
        Catch ex As Exception
            MessageBox.Show("The following error(s) have occurred: " & ex.Message, Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Try
            DES.Key = Hash.ComputeHash(System.Text.ASCIIEncoding.ASCII.GetBytes(TextBox1.Text))
            DES.Mode = Security.Cryptography.CipherMode.ECB
            Dim DESDecrypter As System.Security.Cryptography.ICryptoTransform = DES.CreateDecryptor
            Dim Buffer As Byte() = Convert.FromBase64String(TextBox2.Text)
            TextBox2.Text = System.Text.ASCIIEncoding.ASCII.GetString(DESDecrypter.TransformFinalBlock(Buffer, 0, Buffer.Length))
        Catch ex As Exception
            MessageBox.Show("The following error(s) have occurred: " & ex.Message, Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try
    End Sub
End Class
Website: <!-- m --><a class="postlink" href="http://www.PBAProductions.com">http://www.PBAProductions.com</a><!-- m -->
E-Mail: <!-- e --><a href="mailtoTongueatrick@AriSystems.Org">Patrick@AriSystems.Org</a><!-- e -->
Skype: Qwaxer
Youtube: Qwaxer
[Image: 2hnx8av.jpg]


Messages In This Thread
Xolara's Tutorials - by xolara - 10-01-2010, 10:14 PM
Re: Xolara's Tutorials - by xolara - 10-01-2010, 10:32 PM
Re: Xolara's Tutorials - by xolara - 10-04-2010, 03:30 PM
Re: Xolara's Tutorials - by xolara - 10-04-2010, 05:27 PM
Re: Xolara's Tutorials - by xolara - 10-04-2010, 06:56 PM
Re: Xolara's Tutorials - by xolara - 10-07-2010, 03:36 AM
Re: Xolara's Tutorials - by xolara - 01-29-2011, 01:17 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Step by Step tutorials of VB! Himansh 1 10,124 09-28-2011, 02:05 AM
Last Post: xolara

Forum Jump:


Users browsing this thread: 1 Guest(s)