Skip to content

Microex.Common.Extensions.Encryption

L edited this page Jan 15, 2018 · 6 revisions

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

命名空间: Microex.Common.Extensions

方法

名称 说明
ComputeMd5(String) 获得字符串的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