Skip to content

Instantly share code, notes, and snippets.

@garganshul108
Last active June 21, 2020 07:05
Show Gist options
  • Save garganshul108/b06f4a314451808a6870e893aa879fc1 to your computer and use it in GitHub Desktop.
Save garganshul108/b06f4a314451808a6870e893aa879fc1 to your computer and use it in GitHub Desktop.
#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