Click here to Skip to main content
15,886,873 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I want to enter the value as password mode in sql 2005.
I mean ,I want prevent to somebody to see the value of column.
Posted

hi,

encrypt Your password before saving in DB

for encryption write following function
C#
public string GetEncryptedPassword(string password)
    {
        string newPass = string.Empty;
        
        int num = new Random().Next(1, 10);
        foreach (char ch in password)
        {
            newPass += (char)(ch + num);
        }
        newPass += (char)num;
        return newPass;
    }


for Decryption
C#
public string GetDecryptedPassword(string password)
    {
        string decryptedPassword = string.Empty;
        int num = (int)password[password.Length - 1];
        password = password.Remove(password.Length - 1, 1);
        foreach (char ch in password)
        {
            decryptedPassword += (char)(ch - num);
        }
        return decryptedPassword;
    }


Hope it will help u
Best Luck
Happy Codeing:)
 
Share this answer
 
v2
Comments
Member 7909353 4-May-12 0:44am    
how?
Nilesh Patil Kolhapur 4-May-12 0:46am    
check updated solution
BY using Encrypt COncept for example by using hashing algorithms u can encrypt you password and store it in DB and for retriving pupose use same tecnique and decrypt it

Follow this link it has simple encrypt & decrypt algorithm
http://www.dotnetstuff.co.cc/2011/12/encript-string-in-net.html[^]
 
Share this answer
 
v2
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900