Jump to content

php to generate 13 character password


kaliok

Recommended Posts

I am having some trouble protecting a folder of movie files.I am using htaccess and htpasswd  to do this. I need to have the ability to add additional users to the list, but I need to give the admin person the ability to do this. The method I thought I could use was to have a php script that would take the new username and password that are entered and then write that to the htpasswd file. I have not been able to locate a php script that generates a 13 character password. There are several places I have found that have a form to generate these types of passwords but I would like the php to do this for me.


$pwFile = "../private/.htpasswd";
$fh = fopen($pwFile, 'a') or die("can't open file");
$rawpassword = ($enteredpassword);
$password = crypt($rawpassword); 
$myNewCombo = "$UserName:$password";
fwrite($fh, $myNewCombo);
fclose($fh);

 

The above code generates a password that is too long, I am guessing it is something I am doing wrong with crypt, perhaps it is the wrong function to use. Any help advice is much appreciated.

 

Link to comment
https://forums.phpfreaks.com/topic/108961-php-to-generate-13-character-password/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.