就是在.NET环境下如何:算法一:加载公钥,算法二验证用:SHA-1签名过的数据的验签算法

解决方案 »

  1.   

    .NET 自己带的有把     /// <summary>
            /// 获取SHA1
            /// </summary>
            /// <param name="p_Bytes">基本数据</param>
            /// <param name="p_StarIndex">开始位置</param>
            /// <param name="p_Count">数量</param>
            /// <returns>SHA1码</returns>
            private string GetInfoSHA1(byte[] p_Bytes, int p_StarIndex, int p_Count)
            {
                System.IO.MemoryStream _KeyMemory = new System.IO.MemoryStream(p_Bytes, p_StarIndex, p_Count);
                byte[] _InfoBytes = new byte[_KeyMemory.Length];
                _KeyMemory.Read(_InfoBytes, 0, _InfoBytes.Length);
                _KeyMemory.Close();
                System.Security.Cryptography.SHA1CryptoServiceProvider _SHA1 = new System.Security.Cryptography.SHA1CryptoServiceProvider();
                byte[] ShaData = _SHA1.ComputeHash(_InfoBytes);            string _ReturnSH1 = "";            for (int i = 0; i != ShaData.Length; i++)
                {
                    _ReturnSH1 += ShaData[i].ToString("X02");
                }            return _ReturnSH1;
            }
      

  2.   

    .NET 自己带的有把     /// <summary>
            /// 获取SHA1
            /// </summary>
            /// <param name="p_Bytes">基本数据</param>
            /// <param name="p_StarIndex">开始位置</param>
            /// <param name="p_Count">数量</param>
            /// <returns>SHA1码</returns>
            private string GetInfoSHA1(byte[] p_Bytes, int p_StarIndex, int p_Count)
            {
                System.IO.MemoryStream _KeyMemory = new System.IO.MemoryStream(p_Bytes, p_StarIndex, p_Count);
                byte[] _InfoBytes = new byte[_KeyMemory.Length];
                _KeyMemory.Read(_InfoBytes, 0, _InfoBytes.Length);
                _KeyMemory.Close();
                System.Security.Cryptography.SHA1CryptoServiceProvider _SHA1 = new System.Security.Cryptography.SHA1CryptoServiceProvider();
                byte[] ShaData = _SHA1.ComputeHash(_InfoBytes);            string _ReturnSH1 = "";            for (int i = 0; i != ShaData.Length; i++)
                {
                    _ReturnSH1 += ShaData[i].ToString("X02");
                }            return _ReturnSH1;
            }