Skip to content

Instantly share code, notes, and snippets.

@cvonkleist
Created November 29, 2009 19:42
Show Gist options
  • Save cvonkleist/245035 to your computer and use it in GitHub Desktop.
Save cvonkleist/245035 to your computer and use it in GitHub Desktop.
#include <unistd.h>
#include <stdio.h>
#include <string.h>
int main(int argc, char **argv) {
char buf[14];
char *pass, *salt;
if(argc < 3) {
printf("usage: %s password salt\n", argv[0]);
return 1;
}
pass = argv[1];
salt = argv[2];
if(strlen(salt) > 8)
salt[8] = '\0';
snprintf(buf, 13, "$1$%-6s$", salt);
printf("%s", crypt(pass, buf));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment