How to hash the data [One way encryption]

Posted by Goldytech under C# category on | Views : 3037
Security is the most important aspect of the any application. It always make sense to hash the passwords and other critical information of the customers so that even if goes into wrong hands , the hackers can't do much with it.
This algorithim will hash into a 20 bytes array.

private byte[] getHashPwd(string pwd)
byte[] pwdBytes;
pwdBytes = new byte[pwd.Length - 1];
ASCIIEncoding asciVal = new ASCIIEncoding();
int i=0;
asciVal.GetBytes(pwd,i,pwd.Length-1 ,pwdBytes ,i);
System.Security.Cryptography.SHA1CryptoServiceProvider shaHash = new System.Security.Cryptography.SHA1CryptoServiceProvider();
byte[] returnArray;
returnArray = shaHash.ComputeHash(pwdBytes);
return returnArray;

To call this function
byte[] hashPwd = getHashPwd("goldytech");

Comments or Responses

Login to post response