先获取密码:

生成sha1密码字符串
static void Main(string[] args)
{
try
{
//写法一
var shastr = new SHA1CryptoServiceProvider().ComputeHash(new UnicodeEncoding().GetBytes("Jin888888"));
var shabytestr = ByteArrayToHexString(shastr);
Console.WriteLine("0x"+shabytestr);
//写法二
var sea = "0x" + EncryptSHA1("Jin888888");
Console.WriteLine(sea);
//写法三
byte[] cleanBytes = Encoding.Unicode.GetBytes("Jin888888");
byte[] hashedBytes = System.Security.Cryptography.SHA1.Create().ComputeHash(cleanBytes);
string sign = BitConverter.ToString(hashedBytes).Replace("-", "").ToUpper();
Console.WriteLine("0x" + sign);
Console.ReadKey();
}
catch (Exception ex)
{
throw;
}
}
private static string ByteArrayToHexString(byte[] buf)
{
return BitConverter.ToString(buf).Replace("-", "");
}
public static string EncryptSHA1(string input)
{
byte[] inputBytes = Encoding.Unicode.GetBytes(input);
SHA1 sha = new SHA1CryptoServiceProvider();
byte[] result = sha.ComputeHash(inputBytes);
StringBuilder sBuilder = new StringBuilder();
for (int i = 0; i < result.Length; i++)
{
sBuilder.Append(result[i].ToString("X2"));
}
return sBuilder.ToString();
}
--修改密码
--参考:https://blog.csdn.net/yuhu1023/article/details/88383119
UPDATE dbo.AccountsUsers SET Password=CONVERT(varbinary(512),0x6ED5833CF35286EBF8662B7B5949F0D742BBEC3F) WHERE UserId=2157
--获取字符串二进制流
--参考:https://www.cnblogs.com/qing-xuanlvyee/articles/4756954.html
select convert (varbinary(256),'123456') AS binvalue
--将流拼接输出为字符串
DECLARE @binvalue VARBINARY(256),
@vcharvalue NVARCHAR(256);
SET @binvalue = 0xF5FF3FED3B055DF7EC27251FBC80EE48;
SELECT @vcharvalue = N'aa' + master.dbo.fn_varbintohexsubstring(1, @binvalue, 1, 0);
PRINT @vcharvalue;
C# string类型和byte[]类型相互转换
https://www.jianshu.com/p/766e12c66db8
C# 获取文件MD5、SHA1
https://www.cnblogs.com/shy1766IT/p/7307142.html
将String转化成Stream,将Stream转换成String, C# Stream 和 byte[] 之间的转换(文件流的应用)
















