<% response.Buffer = True %> <%@ Page Language="VB" Debug="true" %> <%'Importazione Ns %> <% @Import NameSpace="System.Drawing" %> <% @Import NameSpace="System.Drawing.Graphics" %> <% @Import NameSpace="System.Drawing.Imaging" %> <% @Import Namespace="System" %> <% @Import Namespace="System.IO" %> <% 'walter.mollica@gmail.com Dim stringa as String Dim dSfondo as Boolean Dim bm As new bitmap(110,30) Dim Rand as New Random() 'Linee Dim a() as single = {rand.next(0,110),rand.next(0,110),rand.next(0,110),rand.next(0,110),rand.next(0,110)} Dim f() as single = {rand.next(0,110),rand.next(0,110),rand.next(0,110),rand.next(0,110),rand.next(0,110)} 'Cifre Dim i() as string = {rand.next(0,10),rand.next(0,10),rand.next(0,10),rand.next(0,10),rand.next(0,10)} Dim xPos as single = rand.next(0,5) stringa = i(3) & i(xPos) & i(0) & i(1) & i(4) & i(2) 'Hash numero (al contrario) Response.Cookies("Numero")("Num") = StrReverse(FormsAuthentication.HashPasswordForStoringInConfigFile(stringa, "sha1")) & (xPos+1) dim gBm as graphics = graphics.fromImage(bm) 'Font e penne Dim Font1 = New Font("Arial", 27) Dim Font2 = New Font("Verdana", 18) Dim Font3 = New Font("Comic Sans MS", 25) Dim Font4 = New Font("Arial", 27) Dim Font5 = New Font("Comic Sans MS", 18) Dim Pen = New Pen(Color.Red,1) Dim Pen2 = New Pen(Color.DarkGray,1) Dim Pen3 = New Pen(Color.green,1) Dim Pen4 = New Pen(Color.white,4) 'Disegno linee gBm.DrawLine(Pen4, f(0), 0, f(4), 35) gBm.DrawLine(Pen3, f(1), 0, f(2), 35) gBm.DrawLine(Pen2, f(2), 0, f(3), 35) gBm.DrawLine(Pen4, f(3), 0, f(0), 35) gBm.DrawLine(Pen, f(4), 0, f(1), 35) 'Posizione cifre dim s() as single = {- 6.0 + rand.next(0,11),20.0 +rand.next(0,11),41.0 +rand.next(0,11),60.0 +rand.next(0,11),80.0 +rand.next(0,11)} dim g() as single = {-10.0 + rand.next(0,11),-6.0 +rand.next(0,11),-12.0 +rand.next(0,11),-7.0 +rand.next(0,11),-10.0 +rand.next(0,11)} 'Posizioni e font Dim dPos = New PointF(s(0), g(0)) Dim dPos1 = New PointF(s(1), g(1)) Dim dPos2 = New PointF(s(2), g(2)) Dim dPos3 = New PointF(s(3), g(3)) Dim dPos4 = New PointF(s(4), g(4)) Dim Fontt = New Font("Arial", 12) Dim dPosa = New PointF(-6.0F, -3.0F) Dim Fontt2 = New Font("Arial", 3) Dim dPosb = New PointF(-6.0F, 2.0F) Dim dPosc = New PointF(-6.0F, 8.0F) Dim dPosd = New PointF(-6.0F, 15.0F) Dim dPose = New PointF(-6.0F, 19.0F) Dim dPosf = New PointF(-6.0F, 4.0F) Dim dPosg = New PointF(-6.0F, 21.0F) Dim dPosg2 = New PointF(-6.0F, 15.0F) Dim sfN as single = Rand.Next(0,4) Dim sfC as single = Rand.Next(0,3) Dim bsfondo as SolidBrush 'Colori cifre Dim cifra1 as New SolidBrush(Color.Yellow) Dim cifra2 as New SolidBrush(Color.Black) Dim cifra3 as New SolidBrush(Color.Navy) Dim cifra4 as New SolidBrush(Color.Aqua) 'Colore di sfondo Select Case sfC Case 0 bsfondo = New SolidBrush(Color.LightGray) cifra1 = New SolidBrush(Color.Brown) cifra4 = New SolidBrush(Color.Purple) Case 1 bsfondo = New SolidBrush(Color.LightBlue) cifra4 = New SolidBrush(Color.Green) Case 2 bsfondo = New SolidBrush(Color.DarkGray) End Select Dim sfondo as string Dim overlay as string Select case sfN Case 0 sfondo = "98654345676543345676532467644674565434567544566466544444444444444444444" & vbcrlf & "00000098765434566543456754322321212121234567656787878987873898783948782934832909487" & vbcrlf & "976643423456789097664534534567879897856342342" overlay = "11111111111111111111111111111" & vbcrlf & "1111111111111111111" & vbcrlf & "1111111111111111111111" Case 1 sfondo = "6666666666666666677779999999999996666666664444444444444445" & vbcrlf & "4444448888888884444445555555555444444444444444" & vbcrlf & "8888888888888888888888777777778888" overlay = "22222222222222222222222222" & vbcrlf & "222222222222222222222222222222" & vbcrlf & "2222222222444444444444" Case 2 sfondo = "9865434567654334567653246764467456543456754456646654" & vbcrlf & "00000098765434566543456754322321212121234567656787878987873898783948782934832909487" & vbcrlf & "976643423456789097664534534567879897856342342" overlay = "46767543444462352245000000000" & vbcrlf & "876543212323432343234543234" & vbcrlf & "090909890098789709876" Case 3 sfondo = "888888888888888888888888888888888888888823423534252345234534523452345623563456345634563456345634563456345634563463456" & vbcrlf & "888888888888888888888888888888888888888823423534252345234534523452345623563456345634563456345634563456345634563463456" & vbcrlf & "888888888888888888888888888888888888888823423534252345234534523452345623563456345634563456345634563456345634563463456" overlay = "88888888888888888888888888" & vbcrlf & "888888888888888888888888" & vbcrlf & "8888888888888888888" End Select With gBm 'Scrittura sfondo .DrawString(sfondo, Fontt, bsfondo, dPosa) .DrawString(sfondo, Fontt, bsfondo, dPosb) .DrawString(sfondo, Fontt, bsfondo, dPosc) .DrawString(sfondo, Fontt, bsfondo, dPosd) .DrawString(sfondo, Fontt, bsfondo, dPose) .DrawString(sfondo, Fontt, bsfondo, dPosf) .DrawString(sfondo, Fontt, bsfondo, dPosg) .DrawString(sfondo, Fontt2, bsfondo, dPosa) .DrawString(sfondo, Fontt2, bsfondo, dPosb) .DrawString(sfondo, Fontt2, bsfondo, dPosc) .DrawString(sfondo, Fontt2, bsfondo, dPosd) .DrawString(sfondo, Fontt2, bsfondo, dPose) .DrawString(sfondo, Fontt2, bsfondo, dPosf) .DrawString(sfondo, Fontt2, bsfondo, dPosg) 'Scrittura delle 5 cifre .DrawString(i(0), Font1, cifra1, dPos) .DrawString(i(1), Font2, cifra2, dPos1) .DrawString(i(2), Font3, cifra3, dPos2) .DrawString(i(3), Font4, cifra4, dPos3) .DrawString(i(4), Font5, cifra1, dPos4) 'Stringa in sovrapposizione .DrawString(overlay, Fontt, bsfondo, dPosd) 'Linee in sovrapposizione .DrawLine(Pen, a(0), 0, a(4), 35) .DrawLine(Pen2, a(1), 0, a(2), 35) .DrawLine(Pen3, a(2), 0, a(3), 35) .DrawLine(Pen3, a(4), 0, a(1), 35) End With 'Fine Response.ContentType = "image/gif" bm.Save(Response.OutputStream, ImageFormat.Gif) bm.dispose() gBm.dispose() %>