Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include <math.h>
- using namespace std
- #define EXP(z) (sqrt((z*z*z*z-z)/(2*z))
- char password[30];
- char a[30];
- int ASCI;
- FILE *fp;
- void title(void);
- void head(void);
- void setup(void); // for Setting up of password file
- void confirm_pswrd(void); //will ask for the password & confirm it
- void process_pswrd(void); //for processing the password
- int Get_ASCI(char); //for fetching the asci code
- void encrypt(int); //for encryption
- void decode(void); //For decoding
- void input(void); //for inputting the password
- void choice(void);
- int main()
- {
- title();
- // confirm_pswrd();
- return 0;
- }
- void confirm_pswrd(void)
- {
- fp=fopen("PASSWORD","r");
- if(fp==NULL)
- setup();
- else
- {
- int index;
- fclose(fp);
- input();
- decode();
- index=strcmp(password,a);
- if(index==0)
- {
- printf("THE PASSWORD IS RIGHT\n");
- // choice();
- }
- else
- {
- system("clear");
- printf("THE PASSWORD IS WRONG\nPLEASE TRY AGAIN\n");
- confirm_pswrd();
- }
- }
- }
- int Get_ASCI(char x)
- {
- int k;
- k=x;
- return k;
- }
- void encrypt(y)
- {
- int k,n,i;
- char ch;
- n=sqrt((y*y*y*y-y)/(2*y));
- fp=fopen("PASSWORD","a");
- for(k=0,i=0;k<n;k++)
- {
- ch='*';
- fputc(ch,fp);
- }
- ch=' ';
- printf(" ");
- fputc(ch,fp);
- fclose(fp);
- }
- void process_pswrd(void)
- {
- int i;
- for(i=0;i<=10;i++)
- {
- if(a[i]=='\0')
- {
- break;
- }
- else
- {
- ASCI=Get_ASCI(a[i]);
- encrypt(ASCI);
- }
- }
- }
- void decode(void)
- {
- int n[20],k,j=0,i,a,exp,d,z,y;
- char ch;
- fp=fopen("PASSWORD","r");
- i=0;
- while(ch!= EOF)
- {
- ch=fgetc(fp);
- if(ch=='*')
- {
- i++;
- }
- else
- {
- if(ch!=EOF)
- {
- n[j]=i;
- i=0;
- j++;
- }
- }
- }
- fclose(fp);
- d=j-1;
- for(i=0;i<=d;i++)
- {
- a=n[i];
- for(k=1;k<=123;k++)
- {
- z=k;
- y=k;
- exp=sqrt((z*z*z*z-z)/(2*z));
- if(a==exp)
- {
- password[i]=(char)y;
- }
- }
- }
- }
- void setup(void)
- {
- head();
- printf("\n\n\t\t\tWELCOME TO SETUP WIZARD\n\n\n\n");
- head();
- printf("\n\nPlease input the new password :");
- scanf("%s",a);
- process_pswrd();
- confirm_pswrd();
- }
- void input(void)
- {
- head();
- printf("Enter the password\n");
- scanf("%s",a);
- }
- void choice(void)
- {
- system("clear");
- printf("\n\n\n\n\n\n\t\t\tACCESS GRANTED");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement