To create key value pair for username and password use following command at prompt
htpasswd -c
it will ask New Password:
and Re-type new password :
eg
htpasswd -c .htpasswd gayab
NOTE THAT
The MD5 algorithm used by htpasswd is specific to the Apache software. Passwords encrypted using it will not be usable with other Web servers.
\r\nLonger passwords will be truncated to 255 characters.
\r\nUsernames are limited to 255 bytes and may not include the character
Check out how you can configure apache server to handle basic authentication