<% 'on error resume next Function Captcha(l) Dim a(), b(), c, d, e, g, n g="a,b,c,d,e,f,g,h,i,j,k,l,m," g=g&"n,o,p,q,r,s,t,u,v,w,x,y,z," g=g&"A,B,C,D,E,F,G,H,I,J,K,L,M," g=g&"N,O,P,Q,R,S,T,U,V,W,X,Y,Z," 'g=g&"1,2,3,4,5,6,7,8,9,0" d=Split(g,",") Redim a(l-1) : Redim b(l-1) : c=0 : Randomize Do Until c=l : n=Int(Rnd*Ubound(d)) : b(c)=n : a(c)=d(n) : c=c+1 : Loop e=Join(a,"") : Session("captcha_code")=e Set Jpeg = Server.CreateObject("Persits.Jpeg") Jpeg.Open Server.MapPath("../webimages/transparent.gif") Jpeg.Width = Int((l*12)+30) Jpeg.Height = 28 Jpeg.Canvas.Font.Color = &H000000 Jpeg.Canvas.Font.Family = "Courier New" Jpeg.Canvas.Font.Size = 25 Jpeg.Canvas.Font.Spacing = 10 Jpeg.Canvas.Pen.Color = &H0C6DAA Jpeg.Canvas.Pen.Width = 1 Jpeg.Canvas.Brush.Solid = False Jpeg.Canvas.PrintText 5, 2, e Jpeg.Canvas.DrawBar 1, 1, (l*15), 28 Jpeg.SendBinary Set Jpeg = Nothing End Function ' display image captcha and make a new session value ' any number of characters work ' (use 5 to 7 max for user usability) ' i have tested with 50+ alphanumerics characters and display very well Response.Write Captcha(7) %>