标签:style blog class code java ext
private byte[] GetValidateCodeImage() { string VNum = RndNum(4); Bitmap Img = new Bitmap(VNum.Length * 16, 25); Graphics g = Graphics.FromImage(Img); g.DrawString(VNum, (new Font("Verdana", 10)), (new SolidBrush(Color.FromArgb(85,85,85))), 3, 3); MemoryStream ms = new MemoryStream(); Img.Save(ms, ImageFormat.Png); g.Dispose(); Img.Dispose(); Session["LocalAuthCode"] = VNum; return ms.ToArray(); } private string RndNum(int VcodeNum) { string str = @"0123456789abcdefghigklmnopqrstuvwxyzABCDEFGHIGKLMNOPQRSTUVWXYZ"; string VNum = ""; Random rnd = new Random(); for (int i = 0; i < VcodeNum; i++) { VNum = VNum + str.Substring(0 + rnd.Next(61), 1); } return VNum; }
标签:style blog class code java ext
原文地址:http://www.cnblogs.com/rebecca-ty/p/3716687.html