• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# MD5类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中MD5的典型用法代码示例。如果您正苦于以下问题:C# MD5类的具体用法?C# MD5怎么用?C# MD5使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



MD5类属于命名空间,在下文中一共展示了MD5类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Map

 static Map()
 {
     #if HASH
     hash = MD5.Create();
     #endif
     NameMap = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
 }
开发者ID:Cadla,项目名称:OBFSCTR,代码行数:7,代码来源:Map.cs


示例2: GenerateMD5

 private static void GenerateMD5()
 {
     if (md5Hash == null)
     {
         md5Hash = MD5.Create();
     }
 }
开发者ID:TwoDoomedPenguins,项目名称:TeamManagementTool,代码行数:7,代码来源:MD5_Crypto.cs


示例3: Main

    public static void Main()
    {
        var triplet = new Regex(@"(.)\1\1");
        md5 = MD5.Create();

        salt = Console.ReadLine();
        int keysFound = 0;;
        int index = -1;

        while (keysFound < 64) {
          index++;
          string hash = GetHash(index);
          Match match = triplet.Match(hash);

          if (match.Success) {
        char letter = match.Groups[0].Value[0];
        var fiveOfThem = new Regex(new String(letter, 5));

        for (int j = index + 1; j <= index + 1000; j++) {
          if (fiveOfThem.IsMatch(GetHash(j))) {
            keysFound++;
            break;
          }
        }
          }

          hashCache.Remove(index);
        }

        Console.WriteLine(index);
    }
开发者ID:jayvan,项目名称:advent,代码行数:31,代码来源:14.cs


示例4: CalculateMD5Incremental

 public void CalculateMD5Incremental(byte[] pBuf, int bytesRead)
 {
     if (md5Incremental == null)
         md5Incremental = MD5.Create();
     dummy = pBuf;
     md5Incremental.TransformBlock(pBuf, 0, bytesRead, null, 0);
 }
开发者ID:petredimov,项目名称:Intrensic,代码行数:7,代码来源:CRCHelper.cs


示例5: EncodeTest

 public void EncodeTest()
 {
     const string data = "i am testing";
     MD5 md5 = new MD5();
     var result = md5.Encode(data);
     Assert.IsTrue(result == "C6BD2686D765C25433A11810493987BD");
 }
开发者ID:yz1988computer,项目名称:TD,代码行数:7,代码来源:MD5Test.cs


示例6: Page_Load

 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         string user=Request.QueryString["user"].ToString();
         string pass = Request.QueryString["pass"].ToString();
         MD5 EncodeMDS = new MD5();
         DataSet ds = new DataSet();
         UserManagerSystem UserManage = new UserManagerSystem();
         ds=UserManage.GetUserAccount(user);
         if (ds.Tables.Count > 0)
         {
             if (ds.Tables[0].Rows.Count > 0)
             {
                 string PassUser = ds.Tables[0].Rows[0]["password"].ToString();
                 if (EncodeMDS.Verify(pass, PassUser))
                 {
                     isOk = "ok";
                     string[] userAcount = new string[3];
                     userAcount[0] = ds.Tables[0].Rows[0]["id"].ToString();
                     userAcount[1] = ds.Tables[0].Rows[0]["UserName"].ToString();
                     userAcount[2] = ds.Tables[0].Rows[0]["ContactName"].ToString();
                     Session["infoUser"] = userAcount;
                 }
             }
         }
     }
     catch (Exception ex)
     {
         Console.Write(ex.ToString());
     }
     Response.Write(isOk);
 }
开发者ID:BGCX261,项目名称:zlap-svn-to-git,代码行数:33,代码来源:UserLoginAccount.aspx.cs


示例7: FileSystemProvider

 public FileSystemProvider(string path = null)
 {
     this.md5 = MD5.Create();
     this.binaryFormatter = new BinaryFormatter();
     this.InitializeDirectories(path);
     this.InitializeMetaData();
     this.CheckHashes();
 }
开发者ID:anshox,项目名称:SyncReader,代码行数:8,代码来源:FileSystemProvider.cs


示例8: UploadFile

        // upload

        public async Task<InputFile> UploadFile(string filename, Stream stream, FileUploadProcessHandler handler) {
            TLApi api = await session.GetFileSessionMain();
            long fileId = Helpers.GenerateRandomLong();
            MD5 hash = new MD5();
            
            if(stream.Length < 128*1024) {
                handler(0.0f);
                byte[] data = new byte[stream.Length];
                stream.Read(data, 0, (int) stream.Length);
                bool result = await api.upload_saveFilePart(fileId, 0, data);
                //while(result != true) {
                //    result = await api.upload_saveFilePart(fileId, 0, data);
                //}
                hash.Update(data);
                handler(1.0f);

                return TL.inputFile(fileId, 1, filename, hash.FinalString());
            }

            bool big = stream.Length > 10*1024*1024;
            float allStreamLength = stream.Length;
            int chunkSize = 128*1024;
            int chunkCount = (int) (stream.Length/chunkSize);
            int lastChunkSize = (int) (stream.Length - chunkSize*chunkCount);
            int allChunksCount = chunkCount + (lastChunkSize != 0 ? 1 : 0);

            for(int i = 0; i < chunkCount; i++) {
                handler((float) i*(float) chunkSize/allStreamLength);
                byte[] data = new byte[chunkSize];
                stream.Read(data, 0, chunkSize);
                bool result = big ? await api.upload_saveBigFilePart(fileId, i, allChunksCount, data) : await api.upload_saveFilePart(fileId, i, data);
                
                //while(result != true) {
                //    result = await api.upload_saveFilePart(fileId, i, data);
                //}
                hash.Update(data);
            }

            

            if(lastChunkSize != 0) {
                handler((float) chunkCount*(float) chunkSize/allStreamLength);
                byte[] lastChunkData = new byte[lastChunkSize];
                stream.Read(lastChunkData, 0, lastChunkSize);
                bool lastChunkResult = big ? await api.upload_saveBigFilePart(fileId, chunkCount, allChunksCount, lastChunkData) : await api.upload_saveFilePart(fileId, chunkCount, lastChunkData);
                //while(lastChunkResult != true) {
                //    lastChunkResult = await api.upload_saveFilePart(fileId, chunkCount, lastChunkData);
                //}
                hash.Update(lastChunkData);
            }

            handler(1.0f);
            
            

            return TL.inputFile(fileId, allChunksCount, filename, hash.FinalString());
        }
开发者ID:Grief-Code,项目名称:kilogram,代码行数:59,代码来源:Files.cs


示例9: CalcMd5Hash

 public static string CalcMd5Hash(MD5 md5, string filePath)
 {
     byte[] hash;
     using (var stream = new FileStream(filePath, FileMode.Open, FileAccess.Read))
     {
         hash = md5.ComputeHash(stream);
     }
     return BitConverter.ToString(hash).Replace("-", "");
 }
开发者ID:helgihaf,项目名称:Alpha,代码行数:9,代码来源:Program.cs


示例10: GetMd5Hash

 private string GetMd5Hash(MD5 md5Hash, Stream inputStream)
 {
     byte[] data = md5Hash.ComputeHash(inputStream);
     StringBuilder sBuilder = new StringBuilder();
     for (int i = 0; i < data.Length; i++)
     {
         sBuilder.Append(data[i].ToString("x2"));
     }
     return sBuilder.ToString();
 }
开发者ID:sachokFoX,项目名称:KindleHighlightViewer,代码行数:10,代码来源:MD5Utility.cs


示例11: GetHash

 public static string GetHash(MD5 crypto, string value)
 {
     byte[] hashByte = crypto.ComputeHash(Encoding.UTF8.GetBytes(value));
     StringBuilder sBuilder = new StringBuilder();
     for (int i = 0; i < hashByte.Length; i++)
     {
         sBuilder.Append(hashByte[i].ToString("x2"));
     }
     return sBuilder.ToString();
 }
开发者ID:krishnarajv,项目名称:Code,代码行数:10,代码来源:Security.cs


示例12: CreateFileStream

        public override Stream CreateFileStream(string uploadFileName)
        {
            UploadFileName = uploadFileName;

            FileStream stream = new FileStream(m_TempFilePath, FileMode.CreateNew);

            m_UploadFileMD5 =  MD5CryptoServiceProvider.Create();

            return new CryptoStream(stream, m_UploadFileMD5, CryptoStreamMode.Write);
        }
开发者ID:huchao007,项目名称:bbsmax,代码行数:10,代码来源:FileUploader.cs


示例13: VerifyMd5Hash

        // Verify a hash against a string.
        public static bool VerifyMd5Hash(MD5 md5Hash, string src, string hash)
        {
            // Hash the input.
            string hashOfInput = GetMd5Hash(md5Hash, src);

            // Create a StringComparer an compare the hashes.
            StringComparer comparer = StringComparer.OrdinalIgnoreCase;

            return 0 == comparer.Compare(hashOfInput, hash);
        }
开发者ID:Neilski,项目名称:URF-Identity,代码行数:11,代码来源:MD5Utils.cs


示例14: GetMd5Hash

 public static string GetMd5Hash(MD5 md5Hash, string input)
 {
     byte[] data = md5Hash.ComputeHash(Encoding.UTF8.GetBytes(input));
     StringBuilder sBuilder = new StringBuilder();
     for (int i = 0; i < data.Length; i++)
     {
         sBuilder.Append(data[i].ToString("x2"));
     }
     return sBuilder.ToString();
 }
开发者ID:thapaji,项目名称:BusTicketing,代码行数:10,代码来源:Utility.cs


示例15: GetHash

 public static string GetHash(MD5 hash, string input)
 {
     StringBuilder result = new StringBuilder();
       byte[] data = hash.ComputeHash(Encoding.UTF8.GetBytes(input));
       for (int i = 0; i < data.Length; i++)
       {
     result.Append(data[i].ToString("x2"));
       }
       return result.ToString();
 }
开发者ID:johny1515,项目名称:Bank_REI,代码行数:10,代码来源:HelperMethods.cs


示例16: VerifyHash

        public static bool VerifyHash(MD5 hash, string input, string hashString)
        {
            PTR3Core.LOG.Log(MsgStatusEnum.MS_Info, "Input String: {0}", input);
              PTR3Core.LOG.Log(MsgStatusEnum.MS_Info, "Received Hash: {0}", hashString);
              string hashString1 = GetHash(hash, input);
              PTR3Core.LOG.Log(MsgStatusEnum.MS_Info, "Calculated Hash: {0}", hashString1);

              StringComparer comparer = StringComparer.OrdinalIgnoreCase;
              return comparer.Compare(hashString1, hashString) == 0;
        }
开发者ID:johny1515,项目名称:Bank_REI,代码行数:10,代码来源:HelperMethods.cs


示例17: GetMd5Hash

 private static string GetMd5Hash(MD5 md5Hash, string input)
 {
     byte[] array = md5Hash.ComputeHash(Encoding.UTF8.GetBytes(input));
     StringBuilder stringBuilder = new StringBuilder();
     for (int i = 0; i < array.Length; i++)
     {
         stringBuilder.Append(array[i].ToString("x2"));
     }
     return stringBuilder.ToString();
 }
开发者ID:iowen,项目名称:ysl,代码行数:10,代码来源:PhotoNameGen.cs


示例18: GetMD5HashCode

 private string GetMD5HashCode(MD5 md5Hash, User user)
 {
     byte[] data = md5Hash.ComputeHash(Encoding.UTF8.GetBytes(user.Email + DateTime.UtcNow.ToString() + user.Password));
     StringBuilder sBuilder = new StringBuilder();
     for (int i = 0; i < data.Length; i++)
     {
         sBuilder.Append(data[i].ToString("x2"));
     }
     return sBuilder.ToString();
 }
开发者ID:ShyAlon,项目名称:DeepDev,代码行数:10,代码来源:LoginControllerBase.cs


示例19: VerifyMD5Hash

        /// <summary>
        /// Verify a hash against a string.
        /// </summary>
        /// <param name="md5Hash"></param>
        /// <param name="input"></param>
        /// <param name="hash"></param>
        /// <returns></returns>
        static bool VerifyMD5Hash(MD5 md5Hash, string input, string hash)
        {
            // Hash the input.
            string hashOfInput = GetMD5Hash(md5Hash, input);

            // Create a StringComparer an compare the hashes.
            StringComparer comparer = StringComparer.OrdinalIgnoreCase;

            return comparer.Compare(hashOfInput, hash) == 0;
        }
开发者ID:Ju2ender,项目名称:csharp-e,代码行数:17,代码来源:MD5Util.cs


示例20: NefitEncryption

 public NefitEncryption(string serial, string access, string password)
 {
     _rijndael = new RijndaelManaged();
     _md5 = MD5.Create();
     _rijndael.Mode = CipherMode.ECB;
     _rijndael.Padding = PaddingMode.Zeros;
     _chatKey = GenerateKey(_chat, access, password);
     //_emailKey = GenerateKey(_email, serial, "gservice_smtp");
     //_alarmKey = GenerateKey(_alarm, serial, "gservice_alarm");
 }
开发者ID:ThaStealth,项目名称:NefitSharp,代码行数:10,代码来源:NefitEncryption.cs



注:本文中的MD5类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# MD5CryptoServiceProvider类代码示例发布时间:2022-05-24
下一篇:
C# MCvScalar类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap