Acceptable Extra characters

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
AGISB
Forum Contributor
Posts: 422
Joined: Fri Jul 09, 2004 1:23 am

Acceptable Extra characters

Post by AGISB »

I modified the code of this topic

viewtopic.php?t=24191

to a random generating password script with at least 1 digit and one extra character.

Code: Select all

<?php
		srand((double)microtime()*1000000);
		$acceptable_chars = "abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ123456789";
		$acceptable_num = "123456789";
		$acceptable_extra = "#%§*!%";
		$password_length = 8;
		do {		
			$extra_rand = rand(0, $password_length - 1);
			$num_rand = rand(0, $password_length - 1);
		} while ($extra_rand == num_rand) ;
		for($i = 0;$i < $password_length;$i++) {
			if ($i == $extra_rand) {
				$new_pass .= substr($acceptable_extra, rand(0,strlen($acceptable_extra) - 1), 1);
			} elseif ($i == $num_rand) {
				$new_pass .= substr($acceptable_num, rand(0,strlen($acceptable_num) - 1), 1);
			} else { 
				$new_pass .= substr($acceptable_chars, rand(0,strlen($acceptable_chars) - 1), 1);
			}
		} 

?>
I plan to use those passwords with the http://www.authentication. Does anyone have a list of which extra charaters are allowed?
Any input on which chars to avoid is also appreaciated. (I already took out I and l and O and 0 to avoid possible confusion)

Thanks
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

extra characters allowed where? in a URL, in post data, what?

B and 8, 2 and Z potentially, 6 and G, U and V... A lot of this depends heavily on the font you use.

generally, if you're going for the most non-confusing characters, you don't use symbols and lower case letters.
AGISB
Forum Contributor
Posts: 422
Joined: Fri Jul 09, 2004 1:23 am

Post by AGISB »

I was thinking of allowed in the password dialog box. Most likely this is more of an apache issue than php
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

any characters can be passed, they are all url encoded by the browser and sent, php's core automatically decodes it and presents it to you.
Post Reply