Click here to Skip to main content
15,892,059 members
Articles / Programming Languages / Visual Basic

.NET Encryption Simplified

Rate me:
Please Sign up or sign in to vote.
4.90/5 (209 votes)
28 Jan 2007CPOL10 min read 1.8M   23.8K   586  
A simple, string-oriented class for symmetric encryption, asymmetric encryption, and hashing.
''' <summary>
''' unit tests for the Encryption class to verify correct operation
''' see http://www.nunit.org/index.html
''' </summary>
''' <remarks>
'''   Jeff Atwood
'''   http://www.codinghorror.com/
''' </remarks>
Module Module1

    Sub Main()
        RunUnitTests()
    End Sub

    ''' <summary>
    ''' This would normally be done with the console or GUI nUnit runner
    ''' </summary>
    Sub RunUnitTests()
        Console.WriteLine("running unit tests..")

        '-- in a real testing scenario, you'd determine which
        '-- methods to call based on Reflection and Attributes
        Dim t As New UnitTests
        t.Setup()
        t.Hash()
        t.HashFile()
        t.SaltedHashes()
        t.Symmetric()
        t.SymmetricFile()
        t.Asymmetric()

        Console.WriteLine("complete!")
        Console.WriteLine("Press ENTER to continue...")
        Console.ReadLine()
    End Sub

End Module

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
United States United States
My name is Jeff Atwood. I live in Berkeley, CA with my wife, two cats, and far more computers than I care to mention. My first computer was the Texas Instruments TI-99/4a. I've been a Microsoft Windows developer since 1992; primarily in VB. I am particularly interested in best practices and human factors in software development, as represented in my recommended developer reading list. I also have a coding and human factors related blog at www.codinghorror.com.

Comments and Discussions