Last active
June 21, 2020 07:05
-
-
Save garganshul108/b06f4a314451808a6870e893aa879fc1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
int check_authentication(char* password) | |
{ | |
int auth_flag = 0; | |
char password_buffer[30]; | |
strcpy(password_buffer, password); | |
if (strcmp(password_buffer, "ihaveaverystrongpassword") == 0) | |
auth_flag = 1; | |
if (strcmp(password_buffer, "thisisasuperstrongpassword") == 0) | |
auth_flag = 1; | |
return auth_flag; | |
} | |
int main(int argc, char* argv[]) | |
{ | |
// Checking for correct input format | |
if (argc < 2) { | |
printf("Usage: %s <password>\n", argv[0]); | |
exit(0); | |
} | |
// Authenticating the password | |
if (check_authentication(argv[1])) { | |
printf("Access Granted.\n"); | |
} | |
else { | |
printf("Access Denied.\n"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment