private void button1_Click(object sender, EventArgs e)
{
Encoding myE = Encoding.GetEncoding(
"utf-8"
); ;
string PwdSha=Get_SHA_Method1(
"123456"
).ToString();
//SHA1
string ns = Convert.ToBase64String(System.Text.ASCIIEncoding.Default.GetBytes(PwdSha));
string miwen = Convert.ToBase64String(System.Text.ASCIIEncoding.Default.GetBytes(
"SHA"
+ ns));
textBox1.Text = miwen;
MessageBox.Show(miwen.Length.ToString());
}
public string Get_SHA_Method1(string strSource)
{
//new
System.Security.Cryptography.SHA1 sha = new System.Security.Cryptography.SHA1CryptoServiceProvider();
//
获取密文字节数组
byte[] bytResult = sha.ComputeHash(System.Text.Encoding.Default.GetBytes(strSource));
//
转换成字符串,32位
string strResult = BitConverter.ToString(bytResult);
//BitConverter
转换出来的字符串会在每个字符中间产生一个分隔符,需要去除掉
strResult = strResult.Replace(
"-"
,
""
);
return
strResult;
}