Skip to content

Microex.Common.Extensions.Encryption

L edited this page Jan 21, 2018 · 6 revisions

提供MD5码的生成方法的扩展方法。
若要浏览此类型的源代码,请参阅引用源

命名空间: Microex.Common.Extensions
nuget包:https://www.nuget.org/packages/Microex.Common/

方法

名称 说明 备注
ComputeMd5(String) 获得字符串的MD5码
ComputeMd5(Stream) 获得流的MD5码 已被弃用
ComputeMd5(byte[]) 获得byte数组的MD5码

示例

下面的例子展示了如何调用Microex.Common的扩展方法,得到对应的MS5码。

//string
string testString = "123";
string stringComputValue=testString.ComputeMd5();

//byte[]
string path = "Your path";
FileStream stream = new FileStream(path, FileMode.Open);
//Position should be reset to 0
//Position应该被重置为0
stream.Position = 0;
MemoryStream ms = new MemoryStream();
stream.CopyTo(ms);
byte[] bytes = ms.ToArray();
string byteComputValue = bytes.ComputeMd5();

示例代码链接

Clone this wiki locally