NoNameCracksInc

Java authenticator extended

Jun 12th, 2013
327
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.08 KB | None | 0 0
  1. Simple java authenticator.
  2.  
  3. import java.io.*;
  4. import java.util.*;
  5.  
  6. public class test implements Runnable{
  7.     int code;
  8.     Random random;
  9.     BufferedReader reader;
  10.     Thread thread;
  11.     String answer;
  12.     int intanswer;
  13.    
  14. public void controll(){
  15. if(intanswer != code){
  16.     System.out.println("Authentication failed.");
  17.     System.exit(0);}}
  18.  
  19.  void authenticate()throws IOException{
  20.      thread=new Thread();
  21.      random=new Random();
  22.      reader=new BufferedReader(new InputStreamReader(System.in));
  23.      code=random.nextInt(999999999);
  24.        System.out.println("Please, rewrite generated code below: " + code);
  25.        answer=reader.readLine();
  26.        intanswer=Integer.parseInt(answer);
  27.         try{
  28.             System.out.println("\n" + "Checking...");
  29.             thread.sleep(2500);
  30.             controll();
  31.             System.out.println("Confirming...");
  32.             thread.sleep(3000);
  33.             controll();
  34.             System.out.println("Done!");
  35.         }
  36.         catch(InterruptedException e){System.out.println(e);}
  37.  }
  38. public void run(){}
  39. public static void main(String args[])throws IOException{
  40.     test x = new test();
  41.     x.authenticate();
  42. }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment