标签:param ++ date stringbu dom str next 组成 for
/// <summary>
/// 封装n位验证码的方法 不生成1,l 0,o等字符串;
/// </summary>
/// <param name="len">验证码长度 一般4-6位</param>
/// <returns></returns>
public static string GenerateCaptchaCode(int len) { //组成验证码的字符 char[] date = { ‘a‘, ‘c‘, ‘d‘, ‘e‘, ‘f‘, ‘g‘, ‘k‘, ‘m‘, ‘p‘, ‘r‘, ‘s‘, ‘t‘, ‘w‘, ‘x‘, ‘y‘, ‘3‘, ‘4‘, ‘5‘, ‘7‘, ‘8‘ }; StringBuilder sbCode = new StringBuilder(); Random rand = new Random(); for (int i = 0; i < len; i++) { char ch = date[rand.Next(date.Length)];//[0,date.Length]范围 sbCode.Append(ch); } return sbCode.ToString(); }
标签:param ++ date stringbu dom str next 组成 for
原文地址:https://www.cnblogs.com/x666066/p/10264640.html