using System;
using System.Text;
using System.IO;
using System.Security.Cryptography; namespace ConsoleApplication13
{
class Program
{
static void Main(string[] args)
{
string imgPath1 = @"..\..\Images\lj.jpg";
string imgPath2 = @"..\..\Images\lj2.jpg";
string imgPath3 = @"..\..\Images\lj3.jpg";
string imgPath4 = @"..\..\Images\lj4.jpg";
string md51 = GetMD5(imgPath1);
string md52 = GetMD5(imgPath2);
string md53 = GetMD5(imgPath3);
string md54 = GetMD5(imgPath4);
Console.WriteLine($"path:{imgPath1},md51:{md51}");
Console.WriteLine($"path:{imgPath2},md52:{md52}");
Console.WriteLine($"path:{imgPath3},md53:{md53}");
Console.WriteLine($"path:{imgPath4},md54:{md54}");
Console.ReadLine();
} static string GetMD5(string sourceFile)
{
StringBuilder md5Builder = new StringBuilder();
if (File.Exists(sourceFile))
{
using (MD5 md5Hash = MD5.Create())
{
using(FileStream fs=File.Open(sourceFile,FileMode.Open))
{
byte[] md5Bytes = md5Hash.ComputeHash(fs);
for (int i = ; i < md5Bytes.Length; i++)
{
string sortedByte = md5Bytes[i].ToString("x2");
if (!string.IsNullOrEmpty(sortedByte))
{
md5Builder.Append(sortedByte);
}
}
}
}
}
return md5Builder.ToString();
}
}
}

C# get md5,renamed file and can not change file's md5的更多相关文章

  1. MD5加密解密类(asp.net)&使用MD5过时处理

    加密类 #region ========加密======== /// <summary> /// 加密 /// </summary> /// <param name=&q ...

  2. (转)win7 64 安装mysql-python:_mysql.c(42) : fatal error C1083: Cannot open include file: 'config-win.h': No such file or directory

    原文地址:http://www.cnblogs.com/fnng/p/4115607.html 作者:虫师 今天想在在win7 64位环境下使用python 操作mysql 在安装MySQL-pyth ...

  3. win7 64 安装mysql-python:_mysql.c(42) : fatal error C1083: Cannot open include file: 'config-win.h': No such file or directory

    今天想在在win7 64位环境下使用python 操作mysql 在安装MySQL-python 时报错: _mysql.c _mysql.c(42) : fatal error C1083: Can ...

  4. IO:File类(java.io.File)

    public class File extends Object implements Serializable, Comparable<File> 构造方法: public File(S ...

  5. error BK1506 : cannot open file '.\Debug\????????.sbr': No such file or dire

    http://blog.csdn.net/shuilan0066/article/details/8738035 分类:            调试错误信息2013-03-29 19:08492人阅读 ...

  6. git “bad index file sha1 signature fatal: index file corrupt”错误

    在执行commit或revert等操作时,提示“bad index file sha1 signature fatal: index file corrupt”错误,导致操作失败.这是由于git的in ...

  7. JAVA FILE or I/O学习 - File学习

    public class FileKnow { public static void main(String[] args) { //构建file对象 ,参数表示文件所在的路径 File file = ...

  8. malformed or corrupted AST file。。。module file out of date&#39;

    今天打开了曾经用的一个项目,(曾经的程序是对的)弹出了两个红框 malformed or corrupted AST file...module file out of date'. 这种结构. 解决 ...

  9. adb pull 报错处理:adb: error: cannot create file/directory 'E:\': No such file or directory

    adb pull /sdcard/1.txt e:/ 报错:adb: error: cannot create file/directory 'E:\': No such file or direct ...

随机推荐

  1. 2019-9-11:渗透测试,基础学习,VMware安装centos 7

    VMware Workstation 15 Pro 安装Centos 7,详细图文步骤 1,点击VMware菜单栏的“文件”-->“新建虚拟机”,选择“典型”使用向导创建虚拟机,点击“下一步” ...

  2. 【NHOI2018】衰减

    [解题思路] 显然这题并不难,由于数据范围较小,完全可以用DFS解决. 从原数开始每次变异的图谱,每次记录住当前的路径. 当找到1时就可以输出并回溯了. 小技巧:printf和scanf可以提高输出输 ...

  3. 部署高可用 schduler

    目录 创建 kube-scheduler 证书和私钥 创建和分发 kubeconfig 文件 创建 kube-scheduler 配置文件 创建kube-scheduler启动文件 启动kube-sc ...

  4. Centos Linux下使用Metasploit渗透android

    .newline{display:block}.katex .base{position:relative;white-space:nowrap;width:min-content}.katex .b ...

  5. 文件上传之靶场upload-labs (1-10)

    第一关 sj 绕过 源码如下: lasIndexOf是返回函数最后一次出现的地方(从右到左) substring是用来截取函数的 indexOf是返回 表示从.出现的地方开始截取并判断是否在允许的字符 ...

  6. TestNG系列(二)TestNG注解

    前言 TetsNG提供了很多注解,允许测试人员灵活地组织测试用例 一.@Test @Tets是TestNG的核心注解,被注解的方法,表示为一个测试方法. description属性 @Test(des ...

  7. Python爬虫从入门到精通——基本库re的使用:正则表达式【华为云技术分享】

    置顶:华为云618大促火热进行中,全场1折起,免费抽主机,消费满额送P30 Pro,点此抢购. 正则表达式是处理字符串的强大工具,它有自己特定的语法结构,有了它,实现字符串的检索.替换.匹配验证都不在 ...

  8. 小白探究UE4网络系列(一)、UE4网络基础类分析

    转载请标明出处:http://www.cnblogs.com/zblade/ 一.概要 捣鼓UE4也有两个多月了,从这儿开始,逐步探究UE4中经典的值复制,RPC两种同步方式.想要弄到其复制和调用的原 ...

  9. gsoap使用

    一. 安装gsoap 下载地址:http://sourceforge.net/projects/gsoap2/files/ 解压安装:./configure --prefix=/usr/local/g ...

  10. Xcode编译引用Framework

    需要两步配置 1.在xcode工程的search path下设置要引用的Framework所在路径 2.将Framewoek拖入工程中时 不要选择copy,而选择引用模式.