What kind of algorithm does .htpasswd uses?

It's CRYPT encryption - an old default. You should probably use MD5 or SHA instead - see man htpasswd for more information.

How are you trying to generate your passwords? You could run htpasswd -n -b username password, but most languages probably have a library function for that already.

Perl example:

perl -e 'print crypt("passwordgoeshere","salt") . "\n"'

The second parameter is the salt. As Gerard points out it's better to use a random string as salt.