Last active
June 3, 2017 20:01
-
-
Save qbatten/56deba29527d7fed5e2951d5e148f1ad to your computer and use it in GitHub Desktop.
This file contains 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
#define _XOPEN_SOURCE | |
#include <stdio.h> | |
#include <cs50.h> | |
#include <string.h> | |
#include <ctype.h> | |
#include <unistd.h> | |
#include <stdlib.h> | |
int main (void) | |
{ | |
// Initialize salt and check | |
string check = malloc(5); | |
check = " "; | |
string salt = "aaa"; | |
// Get password and salt | |
printf("4-character password: "); | |
string pwd = malloc(5); | |
pwd = get_string(); | |
//Check salt to ensure it's exactly 2 characters | |
while (strlen(salt) != 2) | |
{ | |
printf("Salt: "); | |
salt = get_string(); | |
} | |
string checkh = malloc(14); | |
checkh = crypt(check, salt); | |
printf("Check: %s\n", checkh); | |
// Get the hash | |
string pwdh = malloc(14); | |
pwdh = crypt(pwd, salt); | |
printf("pwd: %s\n", pwdh); | |
printf("chk: %s\n", checkh); | |
check = "ghgj"; | |
checkh = crypt(check, salt); | |
printf("pwd: %s\n", pwdh); | |
printf("chk: %s\n", checkh); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment