diff -urN busybox.snapshot/include/applets.h busybox-cryptpw/include/applets.h
--- busybox.snapshot/include/applets.h	2005-05-03 21:43:58.000000000 +0200
+++ busybox-cryptpw/include/applets.h	2005-05-05 10:11:48.000000000 +0200
@@ -125,6 +125,9 @@
 #ifdef CONFIG_CRONTAB
 	APPLET(crontab, crontab_main, _BB_DIR_USR_BIN, _BB_SUID_ALWAYS)
 #endif
+#ifdef CONFIG_CRYPTPW
+	APPLET(cryptpw, cryptpw_main, _BB_DIR_USR_BIN, _BB_SUID_NEVER)
+#endif
 #ifdef CONFIG_CUT
 	APPLET(cut, cut_main, _BB_DIR_USR_BIN, _BB_SUID_NEVER)
 #endif
diff -urN busybox.snapshot/include/libbb.h busybox-cryptpw/include/libbb.h
--- busybox.snapshot/include/libbb.h	2005-05-03 21:43:58.000000000 +0200
+++ busybox-cryptpw/include/libbb.h	2005-05-05 10:40:06.000000000 +0200
@@ -435,6 +435,10 @@
 extern char *pw_encrypt(const char *clear, const char *salt);
 extern struct spwd *pwd_to_spwd(const struct passwd *pw);
 extern int obscure(const char *old, const char *newval, const struct passwd *pwdp);
+extern int palindrome(const char *newval);
+extern int simple(const char *newval);
+extern int get_algo(char *a);
+extern char *crypt_make_salt(void);
 
 extern int bb_xopen(const char *pathname, int flags);
 extern ssize_t bb_xread(int fd, void *buf, size_t count);
diff -urN busybox.snapshot/include/usage.h busybox-cryptpw/include/usage.h
--- busybox.snapshot/include/usage.h	2005-05-03 21:43:58.000000000 +0200
+++ busybox-cryptpw/include/usage.h	2005-05-05 10:11:48.000000000 +0200
@@ -271,6 +271,20 @@
 	"\t-d [user]    delete crontab for user\n" \
 	"\t-c dir       specify crontab directory"
 
+#ifdef CONFIG_FEATURE_SHA1_PASSWORDS
+  #define CRYPTPW_ALG_TYPES(a) a
+#else
+  #define CRYPTPW_ALG_TYPES(a)
+#endif
+#define cryptpw_trivial_usage \
+	"[OPTION] string"
+#define cryptpw_full_usage \
+	"Outputs a crypted version of the string.\n" \
+	"Options:\n" \
+	"\t-a\tDefine which algorithm shall be used for the password.\n" \
+	"\t\t\t(Choices: des, md5" \
+	CRYPTPW_ALG_TYPES(", sha1") \
+	". Default is md5.)"
 
 #define cut_trivial_usage \
 	"[OPTION]... [FILE]..."
diff -urN busybox.snapshot/libbb/Makefile.in busybox-cryptpw/libbb/Makefile.in
--- busybox.snapshot/libbb/Makefile.in	2005-05-03 21:43:53.000000000 +0200
+++ busybox-cryptpw/libbb/Makefile.in	2005-05-05 10:42:22.000000000 +0200
@@ -26,10 +26,12 @@
 	bb_asprintf.c ask_confirmation.c change_identity.c chomp.c \
 	compare_string_array.c concat_path_file.c copy_file.c copyfd.c \
 	correct_password.c create_icmp_socket.c create_icmp6_socket.c \
-	device_open.c dump.c error_msg.c error_msg_and_die.c find_mount_point.c \
+	crypt_make_salt.c device_open.c dump.c error_msg.c \
+	error_msg_and_die.c find_mount_point.c \
 	find_pid_by_name.c find_root_device.c fgets_str.c full_read.c \
-	full_write.c get_last_path_component.c get_line_from_file.c get_ug_id.c \
-	get_terminal_width_height.c hash_fd.c herror_msg.c herror_msg_and_die.c \
+	full_write.c get_algo.c get_last_path_component.c get_line_from_file.c \
+	get_ug_id.c get_terminal_width_height.c hash_fd.c herror_msg.c \
+	herror_msg_and_die.c \
 	human_readable.c inet_common.c inode_hash.c interface.c isdirectory.c \
 	kernel_version.c last_char_is.c llist_add_to.c login.c loop.c \
 	make_directory.c mode_string.c module_syscalls.c mtab.c mtab_file.c \
diff -urN busybox.snapshot/libbb/crypt_make_salt.c busybox-cryptpw/libbb/crypt_make_salt.c
--- busybox.snapshot/libbb/crypt_make_salt.c	1970-01-01 01:00:00.000000000 +0100
+++ busybox-cryptpw/libbb/crypt_make_salt.c	2005-05-05 10:39:27.000000000 +0200
@@ -0,0 +1,43 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * crypt_make_salt 
+ *
+ * i64c was also put here, this is the only function that uses it.
+ *
+ * Lifted from loginutils/passwd.c by Thomas Lundquist <thomasez@zelow.no>
+ *
+ */
+
+#include <unistd.h>
+#include <time.h>
+
+#include <libbb.h>
+
+static int i64c(int i)
+{
+	if (i <= 0)
+		return ('.');
+	if (i == 1)
+		return ('/');
+	if (i >= 2 && i < 12)
+		return ('0' - 2 + i);
+	if (i >= 12 && i < 38)
+		return ('A' - 12 + i);
+	if (i >= 38 && i < 63)
+		return ('a' - 38 + i);
+	return ('z');
+}
+
+extern char *crypt_make_salt(void)
+{
+	time_t now;
+	static unsigned long x;
+	static char result[3];
+
+	time(&now);
+	x += now + getpid() + clock();
+	result[0] = i64c(((x >> 18) ^ (x >> 6)) & 077);
+	result[1] = i64c(((x >> 12) ^ x) & 077);
+	result[2] = '\0';
+	return result;
+}
diff -urN busybox.snapshot/libbb/get_algo.c busybox-cryptpw/libbb/get_algo.c
--- busybox.snapshot/libbb/get_algo.c	1970-01-01 01:00:00.000000000 +0100
+++ busybox-cryptpw/libbb/get_algo.c	2005-05-05 10:13:52.000000000 +0200
@@ -0,0 +1,20 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * get_algo 
+ *
+ * Lifted from loginutils/passwd.c
+ *
+ */
+
+#include <string.h>
+
+#include <libbb.h>
+
+extern int get_algo(char *a)
+{
+	int x = 1;					/* standard: MD5 */
+
+	if (strcasecmp(a, "des") == 0)
+		x = 0;
+	return x;
+}
diff -urN busybox.snapshot/libbb/obscure.c busybox-cryptpw/libbb/obscure.c
--- busybox.snapshot/libbb/obscure.c	2005-05-03 21:43:53.000000000 +0200
+++ busybox-cryptpw/libbb/obscure.c	2005-05-05 10:29:29.000000000 +0200
@@ -44,7 +44,7 @@
  * can't be a palindrome - like `R A D A R' or `M A D A M'
  */
 
-static int palindrome(const char *newval)
+extern int palindrome(const char *newval)
 {
 	int i, j;
 
@@ -79,7 +79,7 @@
  * a nice mix of characters.
  */
 
-static int simple(const char *newval)
+extern int simple(const char *newval)
 {
 	int digits = 0;
 	int uppers = 0;
diff -urN busybox.snapshot/loginutils/Config.in busybox-cryptpw/loginutils/Config.in
--- busybox.snapshot/loginutils/Config.in	2005-05-03 21:43:58.000000000 +0200
+++ busybox-cryptpw/loginutils/Config.in	2005-05-05 10:11:48.000000000 +0200
@@ -98,6 +98,12 @@
 	  Note that Busybox binary must be setuid root for this applet to
 	  work properly.
 
+config CONFIG_CRYPTPW
+	bool "cryptpw"
+	default n
+	help
+	  Utility for crypting a string.
+
 config CONFIG_SU
 	bool "su"
 	default n
diff -urN busybox.snapshot/loginutils/Makefile.in busybox-cryptpw/loginutils/Makefile.in
--- busybox.snapshot/loginutils/Makefile.in	2005-05-03 21:43:58.000000000 +0200
+++ busybox-cryptpw/loginutils/Makefile.in	2005-05-05 10:11:48.000000000 +0200
@@ -26,6 +26,7 @@
 LOGINUTILS-y:=
 LOGINUTILS-$(CONFIG_ADDGROUP)	+= addgroup.o
 LOGINUTILS-$(CONFIG_ADDUSER)	+= adduser.o
+LOGINUTILS-$(CONFIG_CRYPTPW)	+= cryptpw.o
 LOGINUTILS-$(CONFIG_GETTY)	+= getty.o
 LOGINUTILS-$(CONFIG_LOGIN)	+= login.o
 LOGINUTILS-$(CONFIG_PASSWD)	+= passwd.o
diff -urN busybox.snapshot/loginutils/cryptpw.c busybox-cryptpw/loginutils/cryptpw.c
--- busybox.snapshot/loginutils/cryptpw.c	1970-01-01 01:00:00.000000000 +0100
+++ busybox-cryptpw/loginutils/cryptpw.c	2005-05-05 12:21:02.000000000 +0200
@@ -0,0 +1,54 @@
+/* vi: set sw=4 ts=4: */
+
+/*
+ * cryptpw.c
+ * 
+ * Cooked from passwd.c by Thomas Lundquist <thomasez@zelow.no>
+ * 
+ */
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "busybox.h"
+
+
+extern int cryptpw_main(int argc, char **argv)
+{
+	char *clear;
+	char *crypted;
+
+	int flag;
+	int algo = 1;				/* -a - password algorithm */
+
+	while ((flag = getopt(argc, argv, "a:")) != EOF) {
+		switch (flag) {
+		case 'a':
+			algo = get_algo(optarg);
+			break;
+		default:
+			bb_show_usage();
+		}
+	}
+
+	if (optind < argc) {
+		clear = argv[optind];
+	} else {
+		bb_show_usage();
+	}
+
+	if (palindrome(clear) || simple(clear)) {
+		fprintf(stderr, "Warning: weak password (continuing).\n");
+	}
+
+	if (algo == 1) {
+		crypted = pw_encrypt(clear, "$1$");
+	} else {
+		crypted = pw_encrypt(clear, crypt_make_salt());
+	}
+
+	printf("%s\n", crypted);
+
+	return (0);
+
+}
diff -urN busybox.snapshot/loginutils/passwd.c busybox-cryptpw/loginutils/passwd.c
--- busybox.snapshot/loginutils/passwd.c	2005-05-03 21:43:58.000000000 +0200
+++ busybox-cryptpw/loginutils/passwd.c	2005-05-05 10:43:41.000000000 +0200
@@ -21,16 +21,6 @@
 static void set_filesize_limit(int blocks);
 
 
-static int get_algo(char *a)
-{
-	int x = 1;					/* standard: MD5 */
-
-	if (strcasecmp(a, "des") == 0)
-		x = 0;
-	return x;
-}
-
-
 static int update_passwd(const struct passwd *pw, char *crypt_pw)
 {
 	char filename[1024];
@@ -286,36 +276,6 @@
 	return 0;
 }
 
-static int i64c(int i)
-{
-	if (i <= 0)
-		return ('.');
-	if (i == 1)
-		return ('/');
-	if (i >= 2 && i < 12)
-		return ('0' - 2 + i);
-	if (i >= 12 && i < 38)
-		return ('A' - 12 + i);
-	if (i >= 38 && i < 63)
-		return ('a' - 38 + i);
-	return ('z');
-}
-
-static char *crypt_make_salt(void)
-{
-	time_t now;
-	static unsigned long x;
-	static char result[3];
-
-	time(&now);
-	x += now + getpid() + clock();
-	result[0] = i64c(((x >> 18) ^ (x >> 6)) & 077);
-	result[1] = i64c(((x >> 12) ^ x) & 077);
-	result[2] = '\0';
-	return result;
-}
-
-
 static int new_password(const struct passwd *pw, int amroot, int algo)
 {
 	char *clear;

