Password Generator


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. function randomStr($length) {
  2. $randomStr = "";
  3. $chars = array('2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'm', 'n', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z');
  4. while(strlen($randomStr) < $length) {
  5. $alt = rand(1,2) % 2;
  6. if (0 == $alt)
  7. $randomStr .= strtoupper($chars[rand(0, count($chars) - 1)]);
  8. else
  9. $randomStr .= $chars[rand(0, count($chars) - 1)];
  10. }
  11. return $randomStr;
  12. }
  13.  
  14. $len = (int) 8; // 1 trillion+ is enough doncha think?
  15.  
  16. if (@strlen($_GET['len']) > 0) {
  17. if (strlen($_GET['len']) > 2)
  18. header('Location:./' . substr(urldecode(addslashes($_GET['len'])), 0, 2));
  19. $len = (int) substr(urldecode(addslashes($_GET['len'])), 0, 2);
  20. }
  21.  
  22. $password = randomStr($len);

URL: http://code.cshaiku.com/code_php_password_generator.php

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.