Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.