Greetings, some time ago i saw a command (i'm guessing from the ldap-utils package) that would encrypt text into one of the encryptions supported by openldap (md5, crypt etc...) anyone know what that command is?
Thanks!
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On 05/09/10 20:08, Miha Krajnc wrote:
Greetings, some time ago i saw a command (i'm guessing from the ldap-utils package) that would encrypt text into one of the encryptions supported by openldap (md5, crypt etc...) anyone know what that command is?
Thanks!
% slappasswd ;
Zdenek
- -- Zdenek Styblik Net/Linux admin OS TurnovFree.net email: stybla@turnovfree.net jabber: stybla@jabber.turnovfree.net
Hmm, sort of. That command puts out passwords in SSHA (the algorithm i use) so i got what i wanted, thanks!
But is there to set a different algorithm? Like crypt, md5 etc...?
2010/5/9 Miha Krajnc miha.krajnc.mb@gmail.com
Greetings, some time ago i saw a command (i'm guessing from the ldap-utils package) that would encrypt text into one of the encryptions supported by openldap (md5, crypt etc...) anyone know what that command is?
Thanks!
-- Lep pozdrav, Miha Krajnc.
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On 05/09/10 20:38, Miha Krajnc wrote:
Hmm, sort of. That command puts out passwords in SSHA (the algorithm i use) so i got what i wanted, thanks!
But is there to set a different algorithm? Like crypt, md5 etc...?
Sure there is.
% man; is your friend ;) % man slappasswd;
Zdenek
- -- Zdenek Styblik Net/Linux admin OS TurnovFree.net email: stybla@turnovfree.net jabber: stybla@jabber.turnovfree.net
2010/5/9 Miha Krajnc miha.krajnc.mb@gmail.com
Greetings, some time ago i saw a command (i'm guessing from the ldap-utils package) that would encrypt text into one of the encryptions supported by openldap (md5, crypt etc...) anyone know what that command is?
Thanks!
-- Lep pozdrav, Miha Krajnc.
% man indeed is my friend :) Thanks for the help!!!
2010/5/9 Miha Krajnc miha.krajnc.mb@gmail.com
Greetings, some time ago i saw a command (i'm guessing from the ldap-utils package) that would encrypt text into one of the encryptions supported by openldap (md5, crypt etc...) anyone know what that command is?
Thanks!
-- Lep pozdrav, Miha Krajnc.
Greetings, some time ago i saw a command (i'm guessing from the ldap-utils package) that would encrypt text into one of the encryptions supported by openldap (md5, crypt etc...) anyone know what that command is?
I bet it's not the same you've seen, anyway I wrote one quick&dirty for me, it creates prompt or read plaintext from stdin, here you go.. One can probably find some other utility to do this..
--------------------- #include <stdio.h> #include <crypt.h> #include <stdlib.h> #include <string.h> #include <fcntl.h> #include <string.h> #include <sys/time.h> #include <time.h> #include <sys/types.h> #include <unistd.h>
#define _XOPEN_SOURCE #define MD5_CRYPT_ENAB yes
/* gcc -Wall -lcrypt encpwd.c -o encpwd */
static void to64(char *s, unsigned long v, int n) { static unsigned char itoa64[] = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; while (--n >= 0) { *s++ = itoa64[v&0x3f]; v >>= 6; } }
extern char *crypt (__const char *__key, __const char *__salt);
char *crypt_make_salt (void) { struct timeval tv; static char result[40];
result[0] = '\0'; strcpy (result, "$1$"); /* magic for the new MD5 crypt() */
gettimeofday (&tv, (struct timezone *) 0); strcat (result, l64a (tv.tv_usec)); strcat (result, l64a (tv.tv_sec + getpid () + clock ()));
if (strlen (result) > 3 + 8) result[11] = '\0';
return result; }
char *pw_encrypt (const char *clear, const char *salt) { static char cipher[128]; char *cp = crypt (clear, salt); strcpy (cipher, cp); return cipher; }
static char *htenc(const char *clearpasswd) { char *res; char salt[9]; (void) srand((int) time((time_t *) NULL)); to64(&salt[0], rand(), 8); salt[8] = '\0'; res = crypt(clearpasswd, salt); return res; }
int main (argc,argv) int argc; char *argv[]; { const char* msg = "Enter password:"; char *clear = NULL;
if ( argc > 1 ) clear = argv[1]; else if ( !(clear = getpass(msg)) || strlen(clear) == 0 ) { fprintf (stderr, ("You entered no password \n")); return 1; }
if (clear) { fprintf (stdout, "Clear text: %s\n",clear); char *unixenc = pw_encrypt(clear,crypt_make_salt()); fprintf (stdout, "Unix encoded: %s ( {CRYPT}%s )\n",unixenc,unixenc); fprintf (stdout, "Apache encoded: %s\n",htenc(clear)); } return 0; }
---------------------------------
openldap-technical@openldap.org