/// <summary> /// 获取验证码图片流 /// </summary> /// <param>验证码个数(codeType设置 > codeLen设置)</param> /// <param>为空表示自由组合 1:小写拼音 2:大写拼音 3:数字 4:汉字</param> /// <returns></returns> public static byte[] GetValidateCodeStream(ref string code, string codeType = "", int codeLen = 0, int fontSize = 18, int width = 120, int height = 30) { //为空自由组合 if (string.IsNullOrWhiteSpace(codeType)) { for (int i = 0; i < codeLen; i++) { codeType += rm.Next(1, 5) + "|"; } } code = CreateCode(codeType); return CreateValidateCodeStream(code, fontSize, width: width, height: height); }
具体参数各位可以看下备注,我这里顺便打包下代码,方便分享和使用:验证码生成示例