Host Verification Certificate

Source: Internet
Author: User

Session ("gif") = RndNum (5)
Me. IMG1.Src = "../vendor_admin/random_image.aspx"

Random_image.aspx:
Imports System. Drawing. Drawing2D
Imports System. Drawing. Imaging
Imports System. Drawing. Text
Imports System. Drawing
Imports System. Text

Partial Class public_random_image
Inherits System. Web. UI. Page

Protected Sub Page_Load (ByVal sender As Object, ByVal e As System. EventArgs) Handles Me. Load

Dim ImagePath As String = "~ /Image/Validator.jpg"

Dim gif As String = Session ("gif") 'rndnum (5)

Dim _ text () As Char = gif. ToCharArray (0, gif. Length)
Gif = _ text (0 ). toString + "" + _ text (1 ). toString + _ text (2 ). toString + "" + _ text (3 ). toString + "" + _ text (4 ). toString

 

'/Create a Bmp bitmap
Dim bitMapImage As Bitmap = New System. Drawing. Bitmap (Server. MapPath (ImagePath ))
Dim graphicImage As Graphics = Graphics. FromImage (bitMapImage)

'/Set the output mode of the paint brush
GraphicImage. SmoothingMode = SmoothingMode. HighQuality 'smoothingmode. HighSpeed
'/Add a text string
GraphicImage. DrawString (gif, New Font ("Arial", 15, FontStyle. Bold), SystemBrushes. WindowText, New Point (0, 0 ))

'/Set the image output format
Response. ContentType = "image/jpeg"

'/Save the data stream
BitMapImage. Save (Response. OutputStream, ImageFormat. Jpeg)

'/Release the occupied Resources
GraphicImage. Dispose ()
BitMapImage. Dispose ()
End Sub

End Class

RndNum class:
'Function name: RndNum
'Function parameter: VcodeNum -- set the number of digits of the returned random string
'Function: generate a random string mixed with numbers and characters
Function RndNum (ByVal VcodeNum) As String
Dim Vchar As String = ", 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"
Dim VcArray () As String = Split (Vchar, ",") 'generates an array of strings
Dim VNum As String = ""
Dim I As Byte
For I = 1 To VcodeNum
Randomize ()
VNum = VNum & VcArray (Int (35 * Rnd () 'array is generally read from 0, so here it is 35 * Rnd

Next
Return VNum

'While (iNum = Convert. ToInt32 (VcArray. Length * random. NextDouble () = VcArray. Length
'Inum = Convert. ToInt32 (VcArray. Length * random. NextDouble ())
'End While
'Vnum + = VcArray (iNum)
End Function

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.