vladkras

PHP weak password generator

Oct 28th, 2013
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.62 KB | None | 0 0
  1. function genPass($length = 6, $type = 'ALL') {
  2.     define('ALL', '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*()_+=-<>?{}[]\,./');
  3.     define('NOSYMBOLS', '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ');
  4.     define('LETTERS', 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ');
  5.     define('CAPITALS', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ');
  6.     define('NUMBERS', '0123456789');
  7.    
  8.     $chars = constant($type);
  9.    
  10.     $randomPassword = '';
  11.     for ($i = 0; $i < $length; $i++) {
  12.         $randomPassword .= $chars[rand(0, strlen($chars) - 1)];
  13.     }
  14.     return $randomPassword;
  15. }
Advertisement
Add Comment
Please, Sign In to add comment