XtrmAddons.Com > Extensions MVC - Web Development

Differents sections of the site

PHP Release

MySQL News

Create .htpasswd file: Tips & Tricks

The .htpasswd files in Apache are used to store authorization data, names and passwords, of users who can have access to the server.
To create a .htpasswd file, just follow the same procedure as described for the creation of a .htaccess file.

Add user in .htpasswd file

A list of users contained in a file consists of a sequence of pairs name:password single line.

Example:
pierette:tulipe
madame.michu:jambon_beurre
administrateur:3g5Jh5yrNdd94S
Apache accepts encrypted passwords. So you can replace the pair name:password by name:encrypted_password

* Use one or the other version of encryption depending on your server and the level of security.
  • Crypt : the most used algorithm, based on DES. UNIX password everywhere, but Apache for Windows or TPF will not accept it.
    For these encrypted passwords, only the first 8 characters count. For example if you encrypt MOTDEPASSE2000 and the user enter MOTDEPASSE2000 or MOTDEPAS only he will be validated.
    This encoding of passwords should be considered low.
  • SHA : Used to facilitate migration to and from servers using Netscape LDIF (LDAP Directory Interchange Format).
  • MD5 : MD5 algorithm based only recognized by Apache.

Encrypt password with htpasswd Unix/Linux

Under Unix/Linux, htpasswd utility comes with Apache and allows users to insert while encoding passwords.
With MD5 method: htpasswd -nbm
$ htpasswd -nbm aName aPassword
aName:$apr1$nYWHFvS/$DCqwh7lTcSYFM4GR1VXag.
With SHA1 method: htpasswd -nbs
$ htpasswd -nbs aName aPassword
aName:{SHA}gwAOoMggrlO2AS0g8AxpFBe/F/U=
With CRYPT method: htpasswd -nbd
$ htpasswd -nbd aName aPassword
aName:O2AS0g8AxpFBe

Encrypt a password on the command line with OpenSSL

OpenSSL can be used to encrypt passwords for a .htpasswd because he knows the CRYPT and MD5 methods used by Apache.
With MD5 method: openssl passwd -apr1
$ openssl passwd -apr1 aPassword
$apr1$nYWHFvS/$DCqwh7lTcSYFM4GR1VXag.
With CRYPT method: openssl passwd -crypt
$ openssl passwd -crypt aPassword
O2AS0g8AxpFBe

Encrypt a password with PHP

Like many other PHP programming language allows you to encrypt data following many algorithms.
You can find here a PHP script to encode your passwords and .htpasswd on your browser.
For salt of the CRYPT method please refer to the documentation PHP Manual - Function crypt

Download script: encrypt a .htpasswd file
* Only methods APR1-MD5 and SHA-Apache run under Windows.

XtrmAddons.Com > News & Feeds

All web news

Apache Foundation

  • Demand for best-in-class Open Source solutions drives landmark achievements Forest Hill, MD -–16 May 2012-– The Apache Software Foundation (ASF), developers, stewards, and incubators of nearly 150 Open Source projects and initiatives, today announced key milestones achieved in the first quarter of 2012. Recognized as one...

  • Easy to use, affordable, and over 300% faster, Open Source Java Enterprise Edition of popular Apache Tomcat application server ideally suited for Cloud environments The Apache Software Foundation (ASF), the all-volunteer developers, stewards, and incubators of nearly 150 Open Source projects...

  • High-performance, fault-tolerant Open Source "Big Data"  powerhouse scales petabytes of data at Adobe, Cisco, IBM, Morningstar, Netflix, PBS, Rackspace, Twitter, US Government, and more.  Forest Hill, MD –24 April 2012– The Apache Software Foundation (ASF), the all-volunteer developers, stewards, and...

  • The Apache Software Foundation (ASF) welcomes Citrix to the roster of sponsors at the Platinum level. "We are pleased to welcome Citrix to our individual and corporate sponsors whose generosity helps advance the day-to-day operations of The Apache Software Foundation," said...

  • Open Source big data tool used for efficient bulk transfer between Apache Hadoop and structured datastores. Forest Hill, MD --The Apache Software Foundation (ASF), the all-volunteer developers, stewards, and incubators of nearly 150 Open Source projects and initiatives, today announced that Apache Sqoop has graduated...

  • Open Source mashup platform provides easy-to-use infrastructure for building and integrating with social media standards including Activity Streams, OpenSocial, W3C Widgets, and more.  Forest Hill, MD -- The Apache Software Foundation (ASF), the all-volunteer developers, stewards, and incubators of nearly 150 Open Source projects...

XtrmAddons.Com > Statistiques and Informations

Site informations

Domain name

We trust 1&1 for our domains - Reserve yours now for only 6.99€ HT (8.36€) per year!

Statistics

Visitors
16
Articles
32
Web Links
9
Articles View Hits
4711

Who's online ?

We have 3 guests and no members online