Skip to content

Instantly share code, notes, and snippets.

@Unlimiter

Unlimiter/crypt.c

Created May 23, 2021
Embed
What would you like to do?
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