[VB.NET]Creating a Basic Captcha String

  • Hello Guest! Welcome to ConsoleCrunch, to help support our site check out the premium upgrades HERE! to get exclusive access to our hidden content.
  • Unable to load portions of the website...
    If you use an ad blocker addon, you should disable it because it interferes with several elements of the site and blocks more than just adverts.
  • Read Rules Before Posting Post Virus Scans with every program.

1UP

Member
Oct 9, 2014
24
10
63
This was something I pulled from a test program I was messing with. I was writing an application to send some information to a remote database and to prevent "flooding" I could write in a captcha. Granted I would never include this because of how simple it is, it was rather easy.

First off our function to create the random string of letters.
Code:
  Private Function generateCaptchaString()
  Dim rand As New Random
  Dim currentLetter As String
  Dim captchaString As String = ""
  For i = 0 To 6
  currentLetter = ChrW(rand.Next(Asc("A"), Asc("Z") + 1))
  captchaString &= currentLetter
  Next

  Return captchaString
  End Function

Then the code for creating the image with the string as apart of it.
Code:
  'Set captchaText to what is generated in the function generateRandomString
  Dim captchaText As String = generateCaptchaString()

  'Creating a bitmap in memory
  Dim captchaBitmap As New Bitmap(200, 40)

  'Creating a Graphic so we can manipulate how the image will look
  Dim captchaGraphic As Graphics = Graphics.FromImage(captchaBitmap)

  Dim captchaFont As New Font("Arial", 14)

  'Set the Text color
  Dim captchaForeColor As New SolidBrush(Color.Blue)

  'Set the background color
  Dim captchaBackgroundColor As New SolidBrush(Color.Yellow)

  captchaGraphic.FillRectangle(captchaBackgroundColor, 0, 0, Width, Height)
  captchaGraphic.DrawString(captchaText, captchaFont, captchaForeColor, 5.0F, 5.0F)

  pict_Captcha.Image = captchaBitmap
 
  • Like
Reactions: Younis
General chit-chat
Help Users
  • No one is chatting at the moment.
  • @ EMRR:
    Can you help me?
  • @ QM|T_JinX:
    het bro nice work man
  • @ QM|T_JinX:
    with ?
  • @ EMRR:
    What do you mean? I can't understand "with ?"
  • @ QM|T_JinX:
    you ask can you help me and i said with what can i help you out
  • @ EMRR:
    Can you help me about share my generated CID's? Where can i share it on this website?
  • @ QM|T_JinX:
    you can put it in cid section or ps3 section in general
  • @ EMRR:
    Ok, thanks :)
  • @ QM|T_JinX:
    np bro
  • Chat Bot:
    EMRR has started a new thread called "Working Console ID" in Console ID's.
  • Chat Bot:
    EMRR has started a new thread called "Console ID 1" in Console ID's.
  • Chat Bot:
    wadu is our newest member. Welcome!
  • Chat Bot:
    EMRR has started a new thread called "Console ID 2" in Console ID's.
  • Chat Bot:
    QM|T_JinX has posted a new reply in the thread "Console ID 2".
  • @ lurch6661:
    gold hen out soon
  • Chat Bot:
    Christo has joined the room.
  • @ lurch6661:
    zap
  • @ lurch6661:
    trying to figure out how to run a rpf files
  • @ lurch6661:
    on gta5
  • @ lurch6661:
    i guess there is a way were you can upload real cars \
  • @ QM|T_JinX:
    rpf is a update like / update.rpf
  • @ lurch6661:
    also i cant find dmz
  • @ lurch6661:
    is that not warzone
    @ lurch6661: is that not warzone