Skip to content

Instantly share code, notes, and snippets.

@ghoomfrog
Created May 23, 2021 04:09
Show Gist options
  • Save ghoomfrog/093f8ddd9607d49659ec7a50e8bd13e7 to your computer and use it in GitHub Desktop.
Save ghoomfrog/093f8ddd9607d49659ec7a50e8bd13e7 to your computer and use it in GitHub Desktop.
The crypt function from unistd.h as a command.
#include <unistd.h>
#include <string.h>
#include <stdio.h>
int main(int argc, char **argv) {
if (argc > 1) {
if (argc > 2) {
char salt[3];
salt[0] = *argv[2];
if (strlen(argv[2]) < 2)
salt[1] = *argv[2];
else
salt[1] = argv[2][1];
salt[2] = 0;
printf("%.*s", 11, crypt(argv[1], salt) + 2);
return 0;
}
else
fputs("crypt: no salt given\n", stderr);
}
else
fputs("crypt: no password given\n", stderr);
return 1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment