ASP.NET Summary (2) - Generate Verification Pictures
Squire: Terrylee
Generate random verification pictures
Instructions:
1
/ ** /
/// The call function generates a picture of the verification code
2
THIS
.CreateCheckcodeImage ();
1
/ ** /
///
5
Private
String
GenerateCheckcode ()
6
{7 int Number; 8 char code; 9 string checkcode = string.empty; 1011 system.random random = new random (); 1213 for (int i = 0; i <5; i ) 14 {15 Number = random.next (); 1617 IF (Number% 2 == 0) 18 CODE = (char) ('0' (Number% 10)); 19 else20 code = (char) ('a' (char) (CHAR) Number% 26)); 2122 Checkcode = code.toString (); 23} 2425 / ** /// Used for client verification code comparison 26 session ["Checkcode"] = Checkcode; 2728 returnckcode; 29}
30
31
/ ** /
///