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 » C# Syntax »

Encrypt or decrypt password or any text in c# with asp.net


Posted Date: 04 Oct 2008    Resource Type: Code Snippets    Category: C# Syntax
Author: Sujit KumarMember Level: Diamond    
Rating: 1 out of 5Points: 10 (Rs 5)



First add these namespace in your application.
//function used to encrypt and decrypt password in C#
//namespace

using System.Collections.Generic;
using System.Text;
using System.Globalization;


#region Encrypt Password
public string EncryptPwd(string szPwd)
{
string str = szPwd;
string szEncrypt = "";
int nIndex = 101, nFormat;
foreach (char c in szPwd)
{
nFormat = ((int)c ^ nIndex) & 0xFF;
szEncrypt += nFormat.ToString("X");
}
return szEncrypt;
}
#endregion

//Function which is used to decrypt password
#region Decrypt Password
public string DecryptPwd(string szPwd)
{
int nLength = szPwd.Length;
string szPwdDecrypt = "";
string szArray = szPwd;
if ((nLength % 2) != 0)
return "";
int ii;
string st;
for (ii = 0; ii < nLength; ii += 2)
{
char[] szByte = new char[8];
szByte[0] = szArray[ii];
szByte[1] = szArray[ii + 1];
szByte[2] = '\0';
st = szByte[0].ToString();
st += szByte[1].ToString();
int uChar = Int32.Parse(st, NumberStyles.HexNumber);
szPwdDecrypt += (char)((uChar ^ 101) & 0xff);
}
return szPwdDecrypt;
}

#endregion // 3 mar 08



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.
Encrypt or decrypt password or any text in c# with asp.net  .  

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: How to build a calendar in ASP
Previous Resource: export excel data into sql server using c#
Return to Discussion Resource Index
Post New Resource
Category: C# Syntax


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use