hello!
if we sign up at a hotmail account or other account we see before submit our information that we must enter a words and that is for prevent "robots" to sign up with hundreds of accounts.
so this characters is an image,so what i want is your help in this:
i want to create this image so what i know is this:
i can generate random characters it's not so difficult and i can build a string from them ,then i can create an image with that string but i can give the string the format that we can see at sign up at any account so i tried to play with "font-family" with no success so i need your help in this and if you can tell me the difference in asp.net=create this image,because i used vb.net with a pictureBox.
thank you very much.

Dani AI

Generated

Short summary for (and following ’s suggestion): a CAPTCHA string is drawn on the server and sent as an image — CSS font-family won’t change what’s already been rasterized into a bitmap. The usual pattern is: generate a random string server‑side, store the correct value on the server (Session, cache, DB) with a short TTL, and expose an image endpoint (Generic Handler / controller action) that returns the rendered bytes with the right ContentType (for example image/png). (sitepoint.com)

A compact VB.NET ASHX example showing the core idea (create bitmap, draw warped text, stream to response):

<%@ WebHandler Language="VB" Class="CaptchaHandler" %>

Imports System.Web
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Drawing.Imaging
Imports System.Web.SessionState

Public Class CaptchaHandler : Implements IHttpHandler, IRequiresSessionState

  Public Sub ProcessRequest(ctx As HttpContext) Implements IHttpHandler.ProcessRequest
    Dim rnd As New Random()
    Dim text = rnd.Next(1000, 9999).ToString()
    ctx.Session("captcha") = text

    Using bmp As New Bitmap(200, 60)
      Using g = Graphics.FromImage(bmp)
        g.SmoothingMode = SmoothingMode.AntiAlias
        g.Clear(Color.White)
        Dim f As New Font("Arial", 28, FontStyle.Bold)
        Dim path As New GraphicsPath()
        path.AddString(text, f.FontFamily, CInt(f.Style), f.Size, New RectangleF(0,0,200,60), StringFormat.GenericDefault)
        path.Warp(New PointF() {New PointF(0,0), New PointF(200,5), New PointF(0,60)}, New RectangleF(0,0,200,60), Nothing, WarpMode.Perspective, 0.5F)
        g.FillPath(Brushes.Black, path)
        ' add lines/dots/noise here before output
      End Using
      ctx.Response.ContentType = "image/png"
      bmp.Save(ctx.Response.OutputStream, ImageFormat.Png)
    End Using
  End Sub

  Public ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable
    Get
      Return False
    End Get
  End Property
End Class

Use GraphicsPath.AddString + GraphicsPath.Warp (or small random rotations, jittered glyph positions, arcs, and line/noise overlays) to get the “distorted” look; see the GraphicsPath/Warp API for details. (learn.microsoft.com)

Notes and cautions: System.Drawing (System.Drawing.Common) works fine on Windows hosts but is not supported on non‑Windows in modern .NET without workarounds — for cross‑platform or cloud hosts prefer a maintained library such as SixLabors.ImageSharp (or SkiaSharp) which has safer server usage patterns. (learn.microsoft.com)

Security: homemade CAPTCHAs can be broken by modern OCR/ML. For production consider a managed service (reCAPTCHA, hCaptcha, etc.) or combine your image CAPTCHA with rate limits, per‑session tokens, short expiry, and secondary checks. ’s pointer to ReCaptcha is sensible for production systems. (developers.google.com)

Recommended Answers

All 3 Replies

thank you for your reply.
first the 2 links are useful,and re-captcha is what i need but not like an application because i don't have a website so i want to build something like that,so just i need to know how can i give that form to the string image.
thank you very much.

if problem is resolved then mark your thread as resolved.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.