public static string Encrypt(string source, Encoding encoding, Md5FormatType type) { string str = Encrypt(source, encoding); var builder = new StringBuilder(0x20); if (type.HasFlag(Md5FormatType.One)) { builder.Append(str.Substring(0, 8)); } if (type.HasFlag(Md5FormatType.Two)) { builder.Append(str.Substring(8, 8)); } if (type.HasFlag(Md5FormatType.Three)) { builder.Append(str.Substring(0x10, 8)); } if (type.HasFlag(Md5FormatType.Four)) { builder.Append(str.Substring(0x18, 8)); } return builder.ToString(); }
public static string Encrypt(string source, Encoding encoding, Md5FormatType type) { string str = Encrypt(source, encoding); var builder = new StringBuilder(0x20); if (type.HasFlag(Md5FormatType.One)) { builder.Append(str.Substring(0, 8)); } if (type.HasFlag(Md5FormatType.Two)) { builder.Append(str.Substring(8, 8)); } if (type.HasFlag(Md5FormatType.Three)) { builder.Append(str.Substring(0x10, 8)); } if (type.HasFlag(Md5FormatType.Four)) { builder.Append(str.Substring(0x18, 8)); } return(builder.ToString()); }
/// <summary> /// 获取Md5信息摘要[按8位一组获取] /// </summary> /// <param name="source">原文</param> /// <param name="encoding"></param> /// <param name="type">获取摘要后的位雄段</param> /// <returns>不管type如何组合,低位在前</returns> public static string Encrypt(string source, Encoding encoding, Md5FormatType type) { var md5 = Encrypt(source, encoding); var sb = new StringBuilder(32); //最多32位 if (type.HasFlag(Md5FormatType.One)) { sb.Append(md5.Substring(0, 8)); } if (type.HasFlag(Md5FormatType.Two)) { sb.Append(md5.Substring(8, 8)); } if (type.HasFlag(Md5FormatType.Three)) { sb.Append(md5.Substring(16, 8)); } if (type.HasFlag(Md5FormatType.Four)) { sb.Append(md5.Substring(24, 8)); } return(sb.ToString()); }
/// <summary> /// 获取Md5信息摘要[按8位一组获取] /// </summary> /// <param name="source">原文</param> /// <param name="encoding"></param> /// <param name="type">获取摘要后的位雄段</param> /// <returns>不管type如何组合,低位在前</returns> public static string Encrypt(string source,Encoding encoding, Md5FormatType type) { var md5 = Encrypt(source,encoding); var sb = new StringBuilder(32); //最多32位 if (type.HasFlag(Md5FormatType.One)) { sb.Append(md5.Substring(0, 8)); } if (type.HasFlag(Md5FormatType.Two)) { sb.Append(md5.Substring(8, 8)); } if (type.HasFlag(Md5FormatType.Three)) { sb.Append(md5.Substring(16, 8)); } if (type.HasFlag(Md5FormatType.Four)) { sb.Append(md5.Substring(24, 8)); } return sb.ToString(); }