In SQL Server I run a command:
Select HASHBYTES('SHA2_256', '12345678') as EncryptedString
It gives 0xEF797C8118F02DFB649607DD5D3F8C7623048C9C063D532CC95C5ED7A898A64F
this string as an output, this string has 66 characters.
On the same side, Itried to encrypt password from C# code, using this:
public string GetSHAEncryptedCode(string Text)
{
//SHA1 sha26 = new SHA1CryptoServiceProvider();
SHA256 sha26 = new SHA256CryptoServiceProvider();
byte[] sha256Bytes = System.Text.Encoding.UTF8.GetBytes(Text);
byte[] cryString = sha26.ComputeHash(sha256Bytes);
string sha256Str = string.Empty;
for (int i = 0; i < cryString.Length; i++)
{
sha256Str += cryString[i].ToString("X");
}
return sha256Str;
}
Suupose, if I enter same "12345678" in C# code it returns me a string of 62 character long, string is EF797C8118F02DFB64967DD5D3F8C762348C9C63D532CC95C5ED7A898A64F
. Now how could i validate the encrypted string coming from sql server and the other string from C# code in order to login the user from login page?