MD5加密C#实现

canca17年前 (2007-03-10)C#300
//此版本支持16位与32位的程序...
//CopyRight(C) CAnca Software Office.
//Created by CAnca.

using System;
using System.IO;
using System.Security.Cryptography;

class App
{
 static void Main()
 {
  string path = @"F:\FileName.exe";
  FileStream fs = new FileStream(path,FileMode.Open,FileAccess.Read);
  MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
  byte [] md5byte = md5.ComputeHash(fs);
  int i,j;
  foreach (byte b in md5byte)
  {
   i = Convert.ToInt32(b);
   j = i >> 4;
   Console.Write(Convert.ToString(j,16));
   j = ((i << 4) & 0x00ff) >> 4;
   Console.Write(Convert.ToString(j,16));
  }
  Console.ReadLine();
 }
}

相关文章

C#字符输出格式控制

  C#的String.Format举例stringstr1 =string.Format("{0:N1}",56789);     &n...

C#引用System.Data.SQLite操作SQLite数据库一例

SQLite数据库结构如下:  引用内容 Create TABLE admin(username text,age integer);下边用C#演示下如何对SQLite数据库进行记录的增、...

发表评论

访客

◎欢迎参与讨论,请在这里发表您的看法和观点。