busybox/loginutils/cryptpw.c
Denis Vlasenko fe7cd642b0 don't pass argc in getopt32, it's superfluous
(add/remove: 0/0 grow/shrink: 12/131 up/down: 91/-727) Total: -636 bytes
   text    data     bss     dec     hex filename
 773469    1058   11092  785619   bfcd3 busybox_old
 772644    1058   11092  784794   bf99a busybox_unstripped
2007-08-18 15:32:12 +00:00

29 lines
724 B
C

/* vi: set sw=4 ts=4: */
/*
* cryptpw.c
*
* Cooked from passwd.c by Thomas Lundquist <thomasez@zelow.no>
*/
#include "libbb.h"
int cryptpw_main(int argc, char **argv);
int cryptpw_main(int argc, char **argv)
{
char salt[sizeof("$N$XXXXXXXX")];
if (!getopt32(argv, "a:", NULL) || argv[optind - 1][0] != 'd') {
strcpy(salt, "$1$");
/* Too ugly, and needs even more magic to handle endianness: */
//((uint32_t*)&salt)[0] = '$' + '1'*0x100 + '$'*0x10000;
/* Hope one day gcc will do it itself (inlining strcpy) */
crypt_make_salt(salt + 3, 4, 0); /* md5 */
} else {
crypt_make_salt(salt, 1, 0); /* des */
}
puts(pw_encrypt(argv[optind] ? argv[optind] : xmalloc_getline(stdin), salt));
return 0;
}