1
using
System;
2
using
System.Collections.Generic;
3
using
System.Text;
4
using
System.Security;
5
using
System.Security.Cryptography;
6
namespace
ConsoleApplication3
7![ExpandedBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
{
8
class Program
9![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
10
static void Main(string[] args)
11![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
12
string a = Console.ReadLine();
13
SHA1 sha=new SHA1CryptoServiceProvider();
14
UTF8Encoding utf = new UTF8Encoding();
15
byte[] s1 = utf.GetBytes(a);
16
byte[] s2 = sha.ComputeHash(s1);
17
sha.Clear();
18
for (int i = 0; i < s2.Length;i++ )
19![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
20
Console.Write("\t"+Convert.ToString(s2[i], 16).PadLeft(2,'0')+" "+s2[i]);
21
22
}
23
Console.Read();
24
}
25
26
27
}
28![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
29
}
![None.gif](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
2
![None.gif](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
3
![None.gif](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
4
![None.gif](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
5
![None.gif](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
6
![None.gif](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
7
![ExpandedBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![ContractedBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
![dot.gif](https://www.cnblogs.com/Images/dot.gif)
8
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
9
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![ContractedSubBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
![dot.gif](https://www.cnblogs.com/Images/dot.gif)
10
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
11
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![ContractedSubBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
![dot.gif](https://www.cnblogs.com/Images/dot.gif)
12
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
13
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
14
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
15
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
16
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
17
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
18
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
19
![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![ContractedSubBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
![dot.gif](https://www.cnblogs.com/Images/dot.gif)
20
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
21
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
22
![ExpandedSubBlockEnd.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
23
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
24
![ExpandedSubBlockEnd.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
25
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
26
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
27
![ExpandedSubBlockEnd.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
28
![InBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
29
![ExpandedBlockEnd.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif)
今天正好碰到,由于C\S和B\S共用,产生了一些无聊的问题,B\S用SHA1加密时字符串长度在40,保持不变,可是C\S用SHA1加密时字符串长度会出现小于40。
由于Byte进行散列时,会有出现0,再进行convert转换时,原本是00的,就变成了0,最后长度就不一了