C# get md5,renamed file and can not change file's md5
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的更多相关文章
- MD5加密解密类(asp.net)&使用MD5过时处理
加密类 #region ========加密======== /// <summary> /// 加密 /// </summary> /// <param name=&q ...
- (转)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 ...
- 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 ...
- IO:File类(java.io.File)
public class File extends Object implements Serializable, Comparable<File> 构造方法: public File(S ...
- 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人阅读 ...
- git “bad index file sha1 signature fatal: index file corrupt”错误
在执行commit或revert等操作时,提示“bad index file sha1 signature fatal: index file corrupt”错误,导致操作失败.这是由于git的in ...
- JAVA FILE or I/O学习 - File学习
public class FileKnow { public static void main(String[] args) { //构建file对象 ,参数表示文件所在的路径 File file = ...
- malformed or corrupted AST file。。。module file out of date'
今天打开了曾经用的一个项目,(曾经的程序是对的)弹出了两个红框 malformed or corrupted AST file...module file out of date'. 这种结构. 解决 ...
- 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 ...
随机推荐
- 在UEFI+GPT下使用rEFind实现Win10 + Kali2.0 双引导
转载自:在UEFI+GPT下使用rEFind实现Win10 + Kali2.0 双引导 https://www.linuxidc.com/Linux/2016-07/133717.htm
- HTML标签-->HTML5新增
HTML的Form新增属性 <form method="post" name="myForm"> <p> 邮箱:<input ty ...
- python中random的基本用法
那么怎么使 a 随机生成一个数值呢,来研究一下random的部分程序:python中random模块的几个函数可以随机生成数值,下面咱们看一下random的几个函数的使用方法. random()是不能 ...
- 使用echarts常用问题总结
1,echarts配合element ui的抽屉插件出现报错,上次解决方法是使用element ui 抽屉的open事件,让在打开事件重新加载,我们项目的需求是点击某个数据,要传递这条数据包含的其他值 ...
- alloc 和 init都做了什么验证。
结论: alloc负责分配内存和创建对象对应的isa指针: init只是返回alloc生成的对象. 所以alloc后,多次调用init,返回的对象是同一个! 代码如下: // // main.m / ...
- 【开发者portal在线开发插件系列二】多条上下行消息(messageId的使用)【华为云技术分享】
前言和基本操作请参考[开发者portal在线开发插件系列一]profile和基本上下行消息,此处不再复述,没操作过的小伙伴一定要先去看看哦~ 话不多说,开始今天的演(表)示(演) 场景说明: 假设一: ...
- NIO-Channel
目录 NIO-Channel 目录 前言 什么是Channel 通道类型 如何使用 ServerSocketChannel SocketChannel FileChannel 总结 相关文献 NIO- ...
- IOS UISwitch 控件
转自:http://my.oschina.net/wolx/blog/396680 一 UISwitch 简介 二 UISwitch 创建 三设置选中状态 四 添加监听 五 测试代码 5.1 代码 5 ...
- [TimLinux] django model关于QuerySet
1. 获取执行过的sql命令 from django.db import connections connections['default'].queries 2. 获取QuerySet将执行的sql ...
- HDU3191-How many paths are there(次短路的长度及其个数)
oooccc1 is a Software Engineer who has to ride to the work place every Monday through Friday. For a ...