Phlip
5/22/2008 3:48:00 AM
Anka Anka wrote:
> How to generate apache password with ruby? I have to generate from ruby
> code the same password like htpasswd2 -m make. In other words: from ruby
> on rails application I have to generate a password, which will be used
> not only for login, but also to generate apache config files (e.g.
> password files for subversion) - so the password must be exactly the
> same.
A password is typically a one-way encryption, such as a hash or CRC
algorithm. If you looked up which one htpasswd2 uses, you could then
get a Ruby library that does it.
Alternately, try some variation of
password = `htpasswd2 -m #{cleartext}`
or system(). That `` notation calls a command line for you.