summaryrefslogtreecommitdiff
path: root/polux/application/busybox/libbb/pw_encrypt.c
diff options
context:
space:
mode:
Diffstat (limited to 'polux/application/busybox/libbb/pw_encrypt.c')
-rw-r--r--polux/application/busybox/libbb/pw_encrypt.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/polux/application/busybox/libbb/pw_encrypt.c b/polux/application/busybox/libbb/pw_encrypt.c
new file mode 100644
index 0000000000..e9cf4e3b8e
--- /dev/null
+++ b/polux/application/busybox/libbb/pw_encrypt.c
@@ -0,0 +1,27 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * Utility routine.
+ *
+ * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
+ *
+ * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
+ */
+
+#include "libbb.h"
+#include <crypt.h>
+
+char *pw_encrypt(const char *clear, const char *salt)
+{
+ /* Was static char[BIGNUM]. Malloced thing works as well */
+ static char *cipher;
+
+#if 0 /* was CONFIG_FEATURE_SHA1_PASSWORDS, but there is no such thing??? */
+ if (strncmp(salt, "$2$", 3) == 0) {
+ return sha1_crypt(clear);
+ }
+#endif
+
+ free(cipher);
+ cipher = xstrdup(crypt(clear, salt));
+ return cipher;
+}