当前位置: 首页>>代码示例>>C#>>正文


C# MD5类代码示例

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


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


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