ARTICLE

Simple Password Encryption Program

Posted by Joshy George Articles | Security in .NET October 31, 2006
This article shows you how to make a simple password encryption program.
Reader Level:
Download Files:
 

Introduction

This article shows you how to make a simple Password encryption Program.

Using the code

The main code used for the conversion is from the Microsoft.VisualBasic class. Below is the code that is used to convert a string to hexadecimal format. We can't direct convert all characters in to hexadecimal format (eg:@#$%^&*()) that's why firstly I take ASCII value of the character, and then convert ASCII value into hexadecimal format.

 

//For this I made while loop

while (Data.Length > 0)

{

    //first I take each character using substring     

sValue= Data.Substring(0, 1).ToString()

//then convert character into ascii.

sValue= Strings.Asc(sValue)

//then convert ascii value into Hex Format

sValue = Conversion.Hex(sValue)

//after converting remove the character.

Data = Data.Substring(1, Data.Length - 1);

sHex = sHex + sValue;

}

 

Ony two functions I used for this application

      

public string PasswordDecription(ref string Data)

{

    string Data1 = "";

    string sData = "";

 

    while (Data.Length > 0)

    {

        Data1 = System.Convert.ToChar(System.Convert.ToUInt32(Data.Substring(0, 2), 16)).ToString();

        sData = sData + Data1;

        Data = Data.Substring(2, Data.Length - 2);

    }

    return sData;

}

 

public string PasswordEncription(ref string Data)

{

    string sValue;

    string sHex = "";

    while (Data.Length > 0)

    {

        sValue = Conversion.Hex(Strings.Asc(Data.Substring(0, 1).ToString()));

        Data = Data.Substring(1, Data.Length - 1);

        sHex = sHex + sValue;

    }

    return sHex;

}

Login to add your contents and source code to this article
post comment
     

To learn more on Password Encryption in .Net with C# Examples and VB.Net Examples In this Example we use MD5 algorithm. Means Encrypt password using MD5 algorithm. Visit this link. http://jayeshsorathia.blogspot.com/2012/08/net-tips-password-encryption-in-net.html

Posted by jayesh sorathia Aug 30, 2012
Posted by jayesh sorathia Aug 30, 2012

Hi Josh thankx for ur usefull code,i have some doubt i am using asp.net with c# plz suggest me where i have to place the code.

Posted by Gopal krishna Dora Dec 28, 2007
COMMENT USING
PREMIUM SPONSORS
DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and add new content to existing PDF documents from within your applications.
Join a Chapter
SPONSORED BY
  • PDF reports have never been easier to create. With our included WYSIWYG Designer, you can layout your reports, set up your data source and let DynamicPDF ReportWriter do the rest.
Join a Chapter