I am working on drupal and i am using

AuthName "Restricted Area"
AuthType digest
AuthUserFile /www/myproject/.htpasswd
AuthGroupFile /dev/null
<Files admin>
require valid-user
</Files>
in htaccess and my htpasswd file contain

admin:yYUhGhiABVJGI
sanjay:aeGwcBYMSYUKc
but I am unable to login. any suggestion

It is possible that you have invalid parameters in your .htaccess file so try following the tutorial at the following link then copy and paste the code.
http://www.password-protection.com/
If however the tutorial is hard to follow or doesn't work then you may find using cpanel or your web administrative panel an easier alternative as some administrative panels that your web host provide such as cpanel will allow all of this code to be generated and placed automatically by the click of a few buttons.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.