[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

MD5 BSD like passwords

Felipe Cruxen

1/13/2007 1:42:00 PM

I'm coding a "postfixadmin" using ruby, so, all the passwords are stored
in DB using a bsd like md5 hash. Is there any simple way I could
generate passwords like that (the same hash could be used to generate
shadow pass?)?.

Really sorry for my lame english, and if the question is stupid, but I'm
a real newbie to ruby.

Thanks in advance.

--
Posted via http://www.ruby-....

4 Answers

Jano Svitok

1/13/2007 1:51:00 PM

0

On 1/13/07, Felipe Cruxen <fcruxen@gmail.com> wrote:
> I'm coding a "postfixadmin" using ruby, so, all the passwords are stored
> in DB using a bsd like md5 hash. Is there any simple way I could
> generate passwords like that (the same hash could be used to generate
> shadow pass?)?.
>
> Really sorry for my lame english, and if the question is stupid, but I'm
> a real newbie to ruby.

you can generate MD5 with:
require 'digest/md5'
hash = Digest::MD5.digest(data) # binary
or hash = Digest::MD5.hexdigest(data) #hexa

F. Senault

1/13/2007 3:50:00 PM

0

Le 13 janvier 2007 à 14:41, Felipe Cruxen a écrit :

> I'm coding a "postfixadmin" using ruby, so, all the passwords are stored
> in DB using a bsd like md5 hash. Is there any simple way I could
> generate passwords like that (the same hash could be used to generate
> shadow pass?)?.

If that's really a BSD-like password (in the form $n$aaaaaaa$aa...), the
crypt function should be able to generate it on a unix system, as long
as you pass the entire salt ($ included) :

>> "password".crypt("$1$Eou1PtvJ$")
=> "$1$Eou1PtvJ$bh2HAitLkEOwoU6Fjuh8i0"

If you take a look at the manpage of the crypt system function (man 3
crypt or http://www.freebsd.org/cgi/man.cgi?query=crypt&... ),
you'll see an explanation of the hash format.

I have no idea of the portability of that function, though. For
instance, it doesn't work on my Windows box, but it works well enough
with FreeBSD and Linux.

Fred
--
You're just a sinner I am told Be your fire when you're cold Make u
happy when you're sad Make u good when u are bad I'm not a human I am
a dove I'm your conscious I am love All I really need is 2 know
that U believe (Prince, I Would Die 4 U)

Felipe Cruxen

1/13/2007 5:12:00 PM

0

Felipe Cruxen wrote:
> I'm coding a "postfixadmin" using ruby, so, all the passwords are stored
> in DB using a bsd like md5 hash. Is there any simple way I could
> generate passwords like that (the same hash could be used to generate
> shadow pass?)?.
>
> Really sorry for my lame english, and if the question is stupid, but I'm
> a real newbie to ruby.
>
> Thanks in advance.

just found out facets library, sorry for the stupid question.

--
Posted via http://www.ruby-....

Felipe Cruxen

1/19/2007 3:56:00 PM

0

Thanks a bunch for the reply. I'll take a good look at the documents.

F. Senault wrote:
> If you take a look at the manpage of the crypt system function (man 3
> crypt or http://www.freebsd.org/cgi/man.cgi?query=crypt&... ),
> you'll see an explanation of the hash format.
>
> I have no idea of the portability of that function, though. For
> instance, it doesn't work on my Windows box, but it works well enough
> with FreeBSD and Linux.
>
> Fred

--
Posted via http://www.ruby-....