Cryptographic Algorithms For VB.NET



I wanted to share some Cryptographic Algorithms with you all and by the way cryptographic is a very important resource for programmers all the way .

Triple DES - triple data encryption (3DES)

Imports System.Text
Imports System.Security.Cryptography

Public Class 3_DES
    Public Shared Function Encrypt(ByVal toEncrypt As String, ByVal key As String, ByVal useHashing As Boolean) As String
  Dim keyArray As Byte()
  Dim toEncryptArray As Byte() = UTF8Encoding.UTF8.GetBytes(toEncrypt)

  If useHashing Then
    Dim hashmd5 As New MD5CryptoServiceProvider()
    keyArray = hashmd5.ComputeHash(UTF8Encoding.UTF8.GetBytes(key))
  Else
    keyArray = UTF8Encoding.UTF8.GetBytes(key)
  End If

  Dim tdes As New TripleDESCryptoServiceProvider()
  tdes.Key = keyArray
  tdes.Mode = CipherMode.ECB
  tdes.Padding = PaddingMode.PKCS7

  Dim cTransform As ICryptoTransform = tdes.CreateEncryptor()
  Dim resultArray As Byte() = cTransform.TransformFinalBlock(toEncryptArray, 0, toEncryptArray.Length)

  Return Convert.ToBase64String(resultArray, 0, resultArray.Length)
    End Function
End Class

How To Make A Simple Text Encrypter(Encryptor),Decrypter(Decryptor) In VB.NET


hello dear readers , now i am up with a simple encryption decryption tutorials in vb.net by the way i am not going to use any classes like RC4,RSA,etc i just wrote the simple method to understand how encryption and encryption works . read how encryption works here and you know what is decryption if there's anyone who don't know what is decryption , decryption make a protected code or whatever visible you can read about that in some other websites ok now lets move to the main part now create a new project and when your form finishes loading add two textboxes and two buttons now place the text box 1 in the top of the form and place the text box2 in the bottom of the form now the textbox1 is for text to input and the textbox2 is for text to output so now change the text of the button 1 to encrypt and the other button to decrypt as you can see how all the controls are arranged in the picture . now double click the form and add this codes ...