Thank you for visiting → Compete For Nothing.com ← If you find anything useful leave me a comment and share. Interested in Arduino, C#, Unity3D, Game Creation, VB.NET, learning and most important of all Sharing!.
Close Notification
Open Notification

VB.NET 2010 MD5 Encryption / Decryption DLL

VB.NET 2010 MD5 Encryption / Decryption DLL
GARD Pro Not Registered
Visual Studio 2010 VB.NET

Visual Studio 2010 VB.NET

Download Project_files Source Code

Download Encryption Decryption Application

GARD Pro Not Registered

Here is the source code for a basic MD5 Encryption and Decryption DLL.

GARD Pro Not Registered

I did not write this code I got it a few years ago from the net somewhere, so
I don’t know who to credit.

Lets get into it.
Create a NEW CLASS LIBRARY project and add this code, add reference to
System.Windows.Forms . Then compile.

Imports System.IO
Imports System.Text
Imports System.Security.Cryptography
Imports System.Windows.Forms


Public Class Crypto

    Private Shared DES As New TripleDESCryptoServiceProvider
    Private Shared MD5 As New MD5CryptoServiceProvider

    Public Shared Function MD5Hash(ByVal value As String) As Byte()
        Return MD5.ComputeHash(ASCIIEncoding.ASCII.GetBytes(value))
    End Function

    Public Shared Function Encrypt(ByVal stringToEncrypt As String, ByVal key As String) As String
        DES.Key = Crypto.MD5Hash(key)
        DES.Mode = CipherMode.ECB
        Dim Buffer As Byte() = ASCIIEncoding.ASCII.GetBytes(stringToEncrypt)
        Return Convert.ToBase64String(DES.CreateEncryptor().TransformFinalBlock(Buffer, 0, Buffer.Length))
    End Function

    Public Shared Function Decrypt(ByVal encryptedString As String, ByVal key As String) As String
        Try
            DES.Key = Crypto.MD5Hash(key)
            DES.Mode = CipherMode.ECB
            Dim Buffer As Byte() = Convert.FromBase64String(encryptedString)
            Return ASCIIEncoding.ASCII.GetString(DES.CreateDecryptor().TransformFinalBlock(Buffer, 0, Buffer.Length))
        Catch ex As Exception
            MessageBox.Show("Invalid Key", "Decryption Failed", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
        End Try
    End Function

Now add your newly created DLL as reference.
Add 2 textboxes
Add 2 Buttons – 1 called btnEncrypt – the other called btnDecrypt

Now the code to use it…

Imports EncryptionDecryption

Public Class Form1

    Private Sub btnEncrypt_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEncrypt.Click
        'This Encrypts the data
        Dim key As String = "123"
        TextBox2.Text = Crypto.Encrypt(TextBox1.Text, key)
        TextBox1.Text = ""
    End Sub

    Private Sub btnDecrypt_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDecrypt.Click
        'This Decrypts the data
        Dim key As String = "123"
        TextBox1.Text = Crypto.Decrypt(TextBox2.Text, key)
        TextBox2.Text = ""
    End Sub
End Class

S0 to use this DLL you need 2 things.

GARD Pro Not Registered
  1. Encryption Key
  2. Text to Encrypt

To Decrypt a message you need to use the same KEY that was used to Encrypt it.

Dogecoin
Donate Dogecoins: DGkJRWQCyBUeXbenYz18LRN9X67aora9nz Whats This?

10 Comments

  1. Thx · June 12, 2013 Reply

    Thanks for help :)

  2. hadi ht · July 18, 2013 Reply

    Thank You warren
    Very Nice Example

  3. PeTeR · January 15, 2014 Reply

    God Work
    It is not a cryptografy, but it’s a HASH
    PeTeR

  4. PeTeR · January 15, 2014 Reply

    PS.
    Please dont use for example:
    Return MD5.ComputeHash(ASCIIEncoding.ASCII.GetBytes(value)), because this option reading not properly
    e,g polish letters ŻŹżźęĘąĄ etc..
    Use the “ASCIIEncoding.UFT8.GetBytes(value)” then will be god!
    Regards, PeTeR

  5. DAVE · January 31, 2014 Reply

    hi. I use your codes but instead of using two textbox and buttons i used it for a log-in interface. encryption works just fine but when i try to decrypt it it says invalid key. i used “123” for key. pls help. thanks in advance

Leave a Reply to DAVE Cancel reply