Thread: need beta testers for this program

  1. #1
    Registered User toaster's Avatar
    Join Date
    Apr 2002
    Posts
    161

    need beta testers for this program

    the source is provided below. this is a low security password program. if you find any errors, loop holes, or have any suggestions on the program (ie: optimizations), please post a response. thanks.

    oh yeah, the password is "this is a secret".
    type in a space, tab, or enter/return after each word.
    you need to type the 4 passwords within 10 seconds (shouldn't be hard to do).

    Code:
    // lock(code4,length8,time10) (_lock.cpp) version gds2002042115beta
    // using MSDEV VSC++ 6.0 (Win32 Console Application)
    
    #include<iostream.h>
    #include<fstream.h>
    //#include<stdlib.h>
    //#include<stdio.h>
    #include<conio.h>
    #include<time.h>
    
    short unsigned int i;
    
    //void option() //removed; obselete
    //{
    // cout<<"enter configuration mode? (y/n)";
    //}
    
    void fillcode(int i)
    {
     for(i;i<8;i++)
     {
      cout<<"*";
     }
     cout<<"]"<<endl;
    }
    
    void inputcode(char*&x)
    {
     cout<<flush;
     for(i=0;i<8;i++)
     {
      x[i]=char(getch());
      cout<<"*"<<flush;
      if(x[i]==char(13)||x[i]=='\t'||x[i]==' '){break;}
     }
     fillcode(++i);
    }
    
    void comparecode(const char*x,const char*y,bool&z)
    {
     for(i=0;i<8;i++)
     {
      if(x[i]==char(13)||x[i]=='\t'||x[i]==' '&&y[i]==NULL)
      {z=true;break;}
      if(x[i]!=y[i])
      {z=false;break;}
     }
    }
    
    int main(void)
    {
     ofstream file("_lock.log",ios::app);
     char *input1=new char[8],code1[8]="this",
          *input2=new char[8],code2[8]="is",
          *input3=new char[8],code3[8]="a",
          *input4=new char[8],code4[8]="secret";
     bool toggle=false;
     time_t start,stop;
    
     while(!toggle)
     {
     cout<<"you have at most (10) seconds to input all required code(s)"<<endl;
     time(&start);
     cout<<"input security lock code 1: [";inputcode(input1);
     cout<<"input security lock code 2: [";inputcode(input2);
     cout<<"input security lock code 3: [";inputcode(input3);
     cout<<"input security lock code 4: [";inputcode(input4);
     time(&stop);
    
     file<<asctime(localtime(&start))<<endl
         <<input1<<endl<<input2<<endl<<input3<<endl<<input4<<endl;
    
     if(difftime(stop,start)<11)
     {
      comparecode(input1,code1,toggle);
      if(!toggle){toggle=false;break;}
      comparecode(input2,code2,toggle);
      if(!toggle){toggle=false;break;}
      comparecode(input3,code3,toggle);
      if(!toggle){toggle=false;break;}
      comparecode(input4,code4,toggle);
      if(!toggle){toggle=false;break;}
     }
     if(toggle)
     {
      delete[]input1;
      delete[]input2;
      delete[]input3;
      delete[]input4;
      cout<<"correct code"<<endl;
      //option(); //obselete
      i=NULL;
      toggle=NULL;
      file<<endl;
      file.close();
      return 0;
     }
     else
     {
      cout<<"invalid code"<<endl;
     }
     } //while
     return 0;
    }
    
    //end of source
    Last edited by toaster; 04-22-2002 at 12:04 AM.
    think only with code.
    write only with source.

  2. #2
    Unregistered
    Guest
    maybe you should remove the time limit. it might help.

  3. #3
    Registered User
    Join Date
    Apr 2002
    Posts
    156
    yeah, I agree
    Compiler: MingW(IDE: Bloodshed Dev-C++ 4.01)
    Web Site: Zoo Crew
    Forums: Zoo Boards
    E-mail: [email protected]

    "Do you wanna go to jail or do you wanna go home?!?!" - Alonzo(Training Day)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help with a program, theres something in it for you
    By engstudent363 in forum C Programming
    Replies: 1
    Last Post: 02-29-2008, 01:41 PM
  2. Replies: 4
    Last Post: 02-21-2008, 10:39 AM
  3. Using variables in system()
    By Afro in forum C Programming
    Replies: 8
    Last Post: 07-03-2007, 12:27 PM
  4. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM