1234567891011121314151617181920212223242526272829303132333435363738394041 |
- using System;
- using System.Collections.Generic;
- using System.Text;
- using System.Security.Cryptography;
- using System.IO;
- namespace Com.Jpsoft.Hospital.Web.Common
- {
- public class MD5Encoding
- {
- public static string GetMD5_Str(string str)
- {
- MD5 md5 = new MD5CryptoServiceProvider();
- byte[] buffer = Encoding.ASCII.GetBytes(str);
- string md5Str = BitConverter.ToString(md5.ComputeHash(buffer)).Replace("-", "").ToLower();
- return md5Str;
- }
- public static byte[] GetMD5_Byte(string str)
- {
- return Encoding.ASCII.GetBytes(GetMD5_Str(str));
- }
- public static string GetMD5_Str(FileStream fs)
- {
- MD5 md5 = new MD5CryptoServiceProvider();
- string md5Str = BitConverter.ToString(md5.ComputeHash(fs)).Replace("-", "").ToLower();
- return md5Str;
- }
- public static byte[] GetMD5_Byte(FileStream fs)
- {
- return Encoding.ASCII.GetBytes(GetMD5_Str(fs));
- }
- }
- }
|