ASP.NET Summary (2) - Generate Verification Pictures

xiaoxiao2021-03-17  212

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

/ ** /

///

2 /// Generate five random strings 3 /// 4 ///

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

/ ** /

///

32 /// Picture of the verification code to display 33 /// 34 ///
转载请注明原文地址:https://www.9cbs.com/read-129659.html

New Post(0)