C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Code Snippets » Encryption »

Password Encryption & Decryption using C#


Posted Date: 07 Aug 2009    Resource Type: Code Snippets    Category: Encryption
Author: AshokMember Level: Gold    
Rating: 1 out of 5Points: 10



Password Encryption & Decryption using C#:



This resource demonstrates to encrypt and decrypt your password as you want.

1. Add reference to the Microsoft.VisualBasic class.
2. Place a Label Control to display the Encrypted Password.
3.Below is the code that is used to convert a string to hexadecimal format. We cannot directly convert all characters into hexadecimal format.So first we take the ASCII value of the character and then convert the ASCII value into hexadecimal format.

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Microsoft.VisualBasic;

public partial class PasswordEncyrption : System.Web.UI.Page
{

protected void Button1_Click(object sender, EventArgs e)
{

string sData = TextBox1.Text;
Label3.Text = PasswordEncryption(ref sData);
Label3.Visible = true;
Label2.Visible = true;
}
protected void Button2_Click(object sender, EventArgs e)
{
string sData = Label3.Text;
TextBox1.Text = PasswordDecription(ref sData);
}
public string PasswordDecryption(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 PasswordEncryption(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;
}

}





Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
Password Encryption & Decryption using C#:  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Encryption and Decryption of a Querystring
Previous Resource: Encryption and Decryption in C#
Return to Discussion Resource Index
Post New Resource
Category: Encryption


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use