- Ubuntu manuals / crypt(3)
Last active
May 6, 2019 02:11
-
-
Save kou1okada/4546073 to your computer and use it in GitHub Desktop.
Unix crypt test
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
TARGETS = unixcrypttest | |
LDLIBS = -lcrypt | |
all: $(TARGETS) | |
clean: | |
-$(RM) $(TARGETS) |
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 <unistd.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <errno.h> | |
#include <err.h> | |
int main(int argc, char *argv[]) | |
{ | |
char *s; | |
if (argc != 3) { | |
printf("Usage: crypttest key salt\n"); | |
printf("salt is a two-character string chosen from the set [a-zA-Z0-9./].\n"); | |
return EXIT_FAILURE; | |
} | |
if (s = crypt(argv[1], argv[2])) { | |
printf("%s\n", s); | |
} else { | |
err(1, NULL); | |
} | |
return errno; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment