工具用途:
产品序列号,设备编号,md5加密字符串获取(支持大小写支持16-32位)
加密举例
123456=e10adc3949ba59abbe56e057f20f883e
123456=49ba59abbe56e057
654321=1511b4f6020ec61d
654321=c33367701511b4f6020ec61ded352059
toutiao.com=cbe956ef91c9f8564d5257e55bddd12e
带密匙的:jiuai=24d6b6666ee742ff85cb845d960462a0 特殊密匙关注后私信我哦
规则中选项均可选:数字(0-9)字母(a-z)大写(A-Z)特殊字符各种标点符号等
规则中的条件至少选一种,条件至少选1种。
带前后缀(自定的)针对待加密的字符串加上指定的前后缀后生成的。目的是混淆加密,看真非实。特殊情况下用。
设计语言:c# + .netframework 3.0
测试环境:win2008R2-x64
///<summary>
///生成随机字符串
///</summary>
///<param name="length">目标字符串的长度</param>
///<param name="useNum">是否包含数字,1=包含,默认为包含</param>
///<param name="useLow">是否包含小写字母,1=包含,默认为包含</param>
///<param name="useUpp">是否包含大写字母,1=包含,默认为包含</param>
///<param name="useSpe">是否包含特殊字符,1=包含,默认为不包含</param>
///<param name="custom">要包含的自定义字符,直接输入要包含的字符列表</param>
///<returns>指定长度的随机字符串</returns>
public static string GetRandomString(int length, bool useNum, bool useLow, bool useUpp, bool useSpe, string custom)
{
byte[] b = new byte[4];
new System.Security.Cryptography.RNGCryptoServiceProvider().GetBytes(b);
Random r = new Random(BitConverter.ToInt32(b, 0));
Random rnd = new Random();
string s = "", str = "",tmp="";
if (useNum == true) { str += "0123456789"; }
if (useLow == true) { str += "abcdefghijklmnopqrstuvwxyz"; }
if (useUpp == true) { str += "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; }
if (useSpe == true) { str += "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~"; }
if (!useNum&&!useLow&&!useUpp&&!useSpe)
{//没有选项默认 数字+小字母
{ str = "0123456789abcdefghijklmnopqrstuvwxyz"; }
}
for (int i = 0; i < length; i++)
{
s += str.Substring(r.Next(0, str.Length - 1), 1);
}
if (is_pre)
tmp = custom + s;//带前缀
else
tmp = s + custom;//带后缀
return tmp;
}
}