C# 工具函数
来源:互联网 发布:java类加载的顺序 编辑:程序博客网 时间:2024/06/04 01:20
#region MD5加密
public static string MD5(string pwd)
{
MD5 md5 = new MD5CryptoServiceProvider();
byte[] data = System.Text.Encoding.Default.GetBytes(pwd);
byte[] md5data = md5.ComputeHash(data);
md5.Clear();
string str = "";
for (int i = 0; i < md5data.Length; i++)
{
str += md5data[i].ToString("x").PadLeft(2, '0');
public static string MD5(string pwd)
{
MD5 md5 = new MD5CryptoServiceProvider();
byte[] data = System.Text.Encoding.Default.GetBytes(pwd);
byte[] md5data = md5.ComputeHash(data);
md5.Clear();
string str = "";
for (int i = 0; i < md5data.Length; i++)
{
str += md5data[i].ToString("x").PadLeft(2, '0');
}
return str;
}
#endregion
#region 分割字符串
/// <summary>
/// 分割字符串
/// </summary>
public static string[] SplitString(string strContent, string strSplit)
{
if (!string.IsNullOrEmpty(strContent))
{
if (strContent.IndexOf(strSplit) < 0)
return new string[] { strContent };
/// <summary>
/// 分割字符串
/// </summary>
public static string[] SplitString(string strContent, string strSplit)
{
if (!string.IsNullOrEmpty(strContent))
{
if (strContent.IndexOf(strSplit) < 0)
return new string[] { strContent };
return Regex.Split(strContent, Regex.Escape(strSplit), RegexOptions.IgnoreCase);
}
else
return new string[0] { };
}
}
else
return new string[0] { };
}
/// <summary>
/// 分割字符串
/// </summary>
/// <returns></returns>
public static string[] SplitString(string strContent, string strSplit, int count)
{
string[] result = new string[count];
string[] splited = SplitString(strContent, strSplit);
/// 分割字符串
/// </summary>
/// <returns></returns>
public static string[] SplitString(string strContent, string strSplit, int count)
{
string[] result = new string[count];
string[] splited = SplitString(strContent, strSplit);
for (int i = 0; i < count; i++)
{
if (i < splited.Length)
result[i] = splited[i];
else
result[i] = string.Empty;
}
{
if (i < splited.Length)
result[i] = splited[i];
else
result[i] = string.Empty;
}
return result;
}
#endregion
}
#endregion
0 0
- C# 工具函数
- C#工具---使用Signature Tool自动生成P/Invoke调用Windows API的C#函数声明
- C# HTML解析工具HtmlAgilityPack XPath 模糊查询not()函数和contains()函数
- 工具函数
- 工具函数
- 工具函数
- 工具函数
- 工具函数
- 工具函数
- C# 函数
- c#函数
- C# 函数
- C# 函数
- c#函数
- C#函数
- C#函数
- C#函数
- 中国移动短信网关CMPP3.0 C#源代码:事件定义及相关工具函数
- Ubuntu安装mysql
- 多连块拼图 (湖南省第七届大学生计算机程序设计竞赛真题) (平移+模拟匹配)
- Javascript判断页面是否加载完成
- c# Hashtable 的使用
- if switch 具体用法 循环 while do while for
- C# 工具函数
- Activity对Dialog的管理
- 大数问题(大明A+B)
- Tautology-状压
- android studio no usages found in project
- Struts2 的Action中取得请求参数值的几种方法
- dz论坛使用七牛加速
- 创建maven的web项目
- 传统方式和spring方式的优缺点