aboutsummaryrefslogtreecommitdiff
path: root/loginutils
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-05-08 23:23:35 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-05-08 23:23:35 +0000
commita035e9f1a9028ad7fb4e9082cc7e383c3e4615cf (patch)
tree089381ac1517da548d262ed60a7b12a742c9ee51 /loginutils
parenta04561f5f7b6f1975c1bded6f11001f03190058c (diff)
downloadbusybox-a035e9f1a9028ad7fb4e9082cc7e383c3e4615cf.tar.gz
cryptpw: forgot svn add... how typical of me :(
Diffstat (limited to 'loginutils')
-rw-r--r--loginutils/cryptpw.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/loginutils/cryptpw.c b/loginutils/cryptpw.c
new file mode 100644
index 000000000..d4bcad3e0
--- /dev/null
+++ b/loginutils/cryptpw.c
@@ -0,0 +1,37 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * cryptpw.c
+ *
+ * Cooked from passwd.c by Thomas Lundquist <thomasez@zelow.no>
+ *
+ */
+
+#include "busybox.h"
+
+int cryptpw_main(int argc, char **argv);
+int cryptpw_main(int argc, char **argv)
+{
+ char *clear;
+ char salt[sizeof("$N$XXXXXXXX")]; /* "$N$XXXXXXXX" or "XX" */
+ const char *opt_a = "md5";
+
+ getopt32(argc, argv, "a:", &opt_a);
+ /* move past the commandline options */
+ /*argc -= optind; - unused */
+ argv += optind;
+
+ crypt_make_salt(salt, 1); /* des */
+ if (strcasecmp(opt_a, "md5") == 0) {
+ strcpy(salt, "$1$");
+ crypt_make_salt(salt + 3, 4);
+ } else if (strcasecmp(opt_a, "des") != 0) {
+ bb_show_usage();
+ }
+
+ clear = argv[0];
+ if (!clear)
+ clear = xmalloc_getline(stdin);
+
+ puts(pw_encrypt(clear, salt));
+ return 0;
+}