CAPTCHA > Java Applet Program

System Security

CAPTCHA > Java Applet Program


CAPTCHA is challenge response test most often placed within form to determine that the user is a human being and not a machine. CAPTCHA is a form of access control.A CAPTCHA images shows a random string which user has to type to submit a form. CAPTCHA generates and grades the test that human can pass but current computer program cannot.since computers are assumed to be unable to solve CAPTCHA,any user entering a correct format is presumed to be human. CAPTCHA are mainly used by websites that offers services like online polls and registration forms.


How TO Run 

  1. Create exp.java file and paste code below in it.
  2. you need four images with file name as moiates,plings,pritio,tibra
  3. run program in applet viewer.
  4. run applet in applet viewer
  5. run applet in browser


import java.awt.*;
import java.awt.event.*;
import java.applet.*;
/* <applet code="exp" width=300 height=300 >
<param name = "Image1" value = "1.png">
<param name = "Image2" value = "2.png">
<param name = "Image3" value = "3.png">
<param name = "Image4" value = "4.png">
</applet>*/
public class exp extends Applet implements ActionListener
{
String msg;
Button submit,change;
TextField nameField;
Image img1;
String filenames[]={"Image1","Image2","Image3","Image1"};
String filetext[]={"moiates","plings","pritio","tibra"};
String filename;
int x;
public void init()
{
setLayout(null);
nameField = new TextField("",5);
submit = new Button("Submit");
add(nameField);
add(submit);
submit.addActionListener(this);
filename=new String(filenames[0]);
img1 = getImage(getDocumentBase(), getParameter(filename));
nameField.setBounds(100,150,100,30);
submit.setBounds(100,200,100,40);
}
public void actionPerformed(ActionEvent ae)
{
String str=nameField.getText();
if(str.equals(filetext[x]))
{
msg="LOG IN";
repaint();
}
else
{
msg="WRONG TRY AGAIN";
x=(int)((Math.random()*100)%4);
filename=new String(filenames[x]);
img1 = getImage(getDocumentBase(), getParameter(filename));
repaint();
}
}

public void paint(Graphics g)
{
g.drawImage(img1, 10,10,this);
g.drawString(msg,100,300);
}
}



Output:



Comments

Popular posts from this blog

Intermediate Code Generation > C Program