Joke Collection Website - Public benefit messages - Java SMS verification code
Java SMS verification code
& lt% @ page contenttype = "image/JPEG; charset = utf-8 " % & gt;
& lt%@page import="java.util.*,java.awt.*,java.awt.image.*,javax.imageio. * " % & gt
& lt% @ page import = " Java . io . output stream " % & gt;
& lthtml & gt
& ltbody & gt
& lt%!
Color getRandColor(int fc,int bc)
{
Random rd = new Random();
if(fc & gt; 255)fc = 255;
if(BC & gt; 255)BC = 255;
int red = fc+rd . nextint(BC-fc);
int green = fc+rd . nextint(BC-fc);
int blue = fc+rd . nextint(BC-fc);
Returns a new color (red, green, blue);
}
% & gt
& lt%
Random r = new Random();
Response.addHeader("Pragma ","no cache ");
response . add header(" Cache-Control "," no-Cache ");
response . adddate header(" expires ",0);
int width = 90
int height = 23
Buffered image pic = new buffered image (width, height, buffered image. TYPE _ INT _ RGB);
graphics GC = pic . get graphics();
gc.setColor(getRandColor(200,250));
gc.fillRect(0,0,width,height);
String[] rNum ={"0 "," 1 "," 2 "," 3 "," 4 "," 5 "," 6 "," 7 "," 8 "," 9 "," a "," b "," c "," d "," e "," f ",
" g "," h "," I "," j "," k "," l "," m "," n "," o "," p "," q "," r "," s "," t "," u "," v "," w ",
“x”,“y”,“z”,“A”,“B”,“C”,“D”,“E”,“F”,“G”,“H”,“I”,“J”,“K”,“L”,“M”,“N”,
“O”、“P”、“Q”、“R”、“S”、“T”、“U”、“V”、“W”、“X”、“Y”、“Z”};
int[] style = {Font。 Ordinary font. Bold, font. Italic, font. Plain color+font. Bold,
Font. Bold+font. Italic, font. Plain color+font. Italic, font. Plain color+font. Bold+font. Italic};
Gc.setColor (color. White);
gc.drawLine(0,30,90, 10);
GC . set color(getRandColor( 160,200));
for(int I = 0; I & lt50; i++)
{
Int x = r.nextInt (width);
int y = r . nextint(height);
int XL = r . nextint( 10);
int yl = r . nextint( 10);
gc.drawLine(x,y,x+xl,y+yl);
}
gc.setColor(getRandColor(60, 150));
String rt =
for(int I = 0; I<4; i++){
string temp = rNum[r . nextint(62)];
rt = rt+temp;
GC . set Font(New Font(" Times New Roman ",style[r.nextInt(7)], 15));
gc.drawString(temp,5+I * 15+r . nextint( 10), 10+r . nextint( 10));
}
GC . dispose();
session.setAttribute("randNum ",rt);
output stream OS = response . get output stream();
ImageIO.write(pic,“JPEG”,OS);
System.out.println ("current verification code is:"+session.getattribute ("randnum"));
OS . flush();
OS . close();
os = null
response . flush buffer();
out . clear();
out = pagecontext . push body();
% & gt
& lt/body & gt;
& lt/html & gt;
- Previous article:Good morning copywriting attracts friends (the most popular sentence is 120)
- Next article:Zhen Zhen called me.
- Related articles
- Say good night to girls and don't reply to text messages.
- Is there a reward for reporting telecom fraud?
- What does it mean to receive a reminder of the deduction from the Nari people?
- How to reply to an invitation?
- If an airplane accident occurs, what methods can passengers use to save themselves?
- How to activate Hangzhou Bank Meituan Credit Card? Depends on the identity of the cardholder.
- Sentences praising astronauts with five rhetorical devices
- The reasons for the formation of sissy
- My friend received the message that my mobile phone was lost, said my name, and then said that he might keep this message.
- Missing text messages between lovers