source: branches/2.2.9/mindi-busybox/loginutils/cryptpw.c @ 2142

Last change on this file since 2142 was 1765, checked in by bruno, 12 years ago

Update to busybox 1.7.2

  • Property svn:eol-style set to native
File size: 724 bytes
Line 
1/* vi: set sw=4 ts=4: */
2/*
3 * cryptpw.c
4 *
5 * Cooked from passwd.c by Thomas Lundquist <thomasez@zelow.no>
6 */
7
8#include "libbb.h"
9
10int cryptpw_main(int argc, char **argv);
11int cryptpw_main(int argc, char **argv)
12{
13    char salt[sizeof("$N$XXXXXXXX")];
14
15    if (!getopt32(argv, "a:", NULL) || argv[optind - 1][0] != 'd') {
16        strcpy(salt, "$1$");
17        /* Too ugly, and needs even more magic to handle endianness: */
18        //((uint32_t*)&salt)[0] = '$' + '1'*0x100 + '$'*0x10000;
19        /* Hope one day gcc will do it itself (inlining strcpy) */
20        crypt_make_salt(salt + 3, 4, 0); /* md5 */
21    } else {
22        crypt_make_salt(salt, 1, 0);     /* des */
23    }
24
25    puts(pw_encrypt(argv[optind] ? argv[optind] : xmalloc_getline(stdin), salt));
26
27    return 0;
28}
Note: See TracBrowser for help on using the repository browser.