Encrypt key with SHA

 public class EncryptHashServicios
{
public EncryptHashServicios()
{
}
#region SHA1
public static byte[] SHA1encrypt(string phrase)
{
return SHA1encrypt(1, phrase);
}
public static byte[] SHA1encrypt(int cycles, string phrase)
{
UTF8Encoding encoder = new UTF8Encoding();
SHA1CryptoServiceProvider sha1hasher = new SHA1CryptoServiceProvider();
byte[] hashedDataBytes = encoder.GetBytes(phrase);
for (int i = 0; i < cycles; i++)
hashedDataBytes = sha1hasher.ComputeHash(hashedDataBytes);
return hashedDataBytes;
}
#endregion
public static string byteArrayToStringHex(byte[] inputArray)
{
StringBuilder output = new StringBuilder("");
for (int i = 0; i < inputArray.Length; i++)
{
output.Append(inputArray[i].ToString("X2"));
}
return output.ToString();
}
public static string byteArrayToStringBase64(byte[] inputArray)
{
return Convert.ToBase64String(inputArray);
}
}
for use this clase only do this.
pass the key string
 byte[] arraykeyencrypted = EncryptHashServicios.SHA1encrypt(key);
string keyencrypted= 
    EncryptHashServicios.byteArrayToStringBase64(arraykeyencrypted);

Ebook Download
View all
Learn
View all