kaliok Posted June 6, 2008 Share Posted June 6, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/108961-php-to-generate-13-character-password/ Share on other sites More sharing options...
severndigital Posted June 6, 2008 Share Posted June 6, 2008 looks like the Standard DES call with crypt would give you the 13 digits you are looking for. http://us3.php.net/manual/en/function.crypt.php Quote Link to comment https://forums.phpfreaks.com/topic/108961-php-to-generate-13-character-password/#findComment-559242 Share on other sites More sharing options...
kaliok Posted June 6, 2008 Author Share Posted June 6, 2008 Ahh. OK DES... that's what I was looking for...didn't know what it was called. Thanks.. I think I may have got it working. Quote Link to comment https://forums.phpfreaks.com/topic/108961-php-to-generate-13-character-password/#findComment-559381 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.