Skip to content

Instantly share code, notes, and snippets.

@kou1okada
Last active May 6, 2019 02:11
Show Gist options
  • Save kou1okada/4546073 to your computer and use it in GitHub Desktop.
Save kou1okada/4546073 to your computer and use it in GitHub Desktop.
Unix crypt test

UNIX crypt test

References

TARGETS = unixcrypttest
LDLIBS = -lcrypt
all: $(TARGETS)
clean:
-$(RM) $(TARGETS)
#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