Created
February 9, 2019 16:21
-
-
Save typelogic/c9078b6358d69926d41b42bc8953de9f to your computer and use it in GitHub Desktop.
snippet: crypt
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
//#define _XOPEN_SOURCE | |
#define _GNU_SOURCE | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
//#include <unistd.h> | |
#include <crypt.h> | |
int main(int argc, char *argv[]) { | |
if ( argc < 3 || (int) strlen(argv[2]) > 16 ) { | |
printf("usage: %s password salt\n", argv[0]); | |
printf("--salt must not larger than 16 characters\n"); | |
return 1; | |
} | |
char salt[21]; | |
sprintf(salt, "$6$%s$", argv[2]); | |
printf("%s\n", crypt((char*) argv[1], (char*) salt)); | |
//printf("%s\n", crypt_r((char*) argv[1], (char*) salt)); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment