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 ...
随机推荐
- Python--将文件夹中图片按照横屏竖屏进行分类
搬运链接:https://www.jianshu.com/p/c8be54282e77 """ 可以遍历输入的路径的指定后缀的文件,主要是用来筛选图片,将图片分成 横屏, ...
- Linux目录结构-上部
第1章 目录结构 1.1 目录结构特点 倒挂的树状结构一切从根开始一切皆文件 1.2 目录结构 /bin 二进制文件 命令 /sbin 超级命令只有root ...
- 【Android - 自定义View】之自定义可滚动的流式布局
首先来介绍一下这个自定义View: (1)这个自定义View的名称叫做 FlowLayout ,继承自ViewGroup类: (2)在这个自定义View中,用户可以放入所有继承自View类的视图,这个 ...
- 【JavaEE】之MyBatis插入数据后获取自增主键
很多时候,我们都需要在插入一条数据后回过头来获取到这条数据在数据表中的自增主键,便于后续操作.针对这个问题,有两种解决方案: 先插入,后查询.我们可以先插入一条数据,然后根据插入的数据的各个字段值,再 ...
- java关键字 保留字
Java 关键字和保留字 Java 关键字列表 (依字母排序 共51组): abstract, assert,boolean, break, byte, case, catch, char, clas ...
- Python批量检测服务器端口可用性与Socket函数使用
socket函数 简述 socket又称套间字或者插口,是网络通信中必不可少的工具.有道是:"无socket,不网络".由于socket最早在BSD Unix上使用,而Unix/L ...
- CSS给元素清除浮动影响的方法,--最全四种方法
代码实例: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF ...
- 卸载&&更新docker(ubuntu)
卸载docker: apt-get purge lxc-docker apt-get autoremove 更新docker: apt-get update apt-get install lxc-d ...
- Bomb后端云使用
Bomb是后台云托管工具,在Bomb官网注册会员,即可免费使用后台数据库服务.https://www.bmob.cn/app/list 创建应用后,在设置里获取密钥.根据官方文档集成. 在集成后运行时 ...
- [TimLinux] WireShark 安装篇——CentOS7
1. 下载 libpcap: http://www.tcpdump.org/release/libpcap-1.9.0.tar.gz cmake: https://github-production- ...