Showing posts with label AES. Show all posts
Showing posts with label AES. Show all posts

AES Encryption and Decryption in VB.NET using Encyption.dll

   Hello World! Sharing with you a very simple .dll to encrypt and decrypt strings using AES Encryption in VB.NET. This DLL (Dynamic Link Library) is useful for storing passwords in your database.

  The Advanced Encryption Standard or AES is a symmetric block cipher used by the U.S. government to protect classified information and is implemented in software and hardware throughout the world to encrypt sensitive data. - Techtarget

   Simply add the following DLL as reference to your project and import Encryption.AESMethod in your code. The following DLL is created using .NET Framework 3.5. Now, how do we use it? Just follow the sample code below. The DLL I created has to functions: Encrypt() and Decrypt(). It also uses a key for encryption.


Imports Encryption.AESMethod

Module Test

    Sub Main()
        Dim OriginalText As String = "arnelrobles.com"
        Dim AESKey As String = "secretkey"
        Dim EncryptedText As String = ""

        EncryptedText = Encrypt(OriginalText, AESKey)
        Console.WriteLine("EncryptedText: " & EncryptedText)
        Console.WriteLine("OriginalText: " & Decrypt(EncryptedText, AESKey))
        Console.ReadLine()
    End Sub

End Module

Output:




   To get a copy of the DLL, just download Encryption.dll. I am also sharing a sample code here, this was created using VS 2013 Community edition.

   Feel free to ask questions by commenting below. You're awesome.