snippets / password

All snippets tagged password (5)

  1. PHP random password

    Generates random php password from [0-9a-z] characters.

    1 <?php echo base_convert(rand(0, PHP_INT_MAX) . rand(0, PHP_INT_MAX), 10, 36);
    Posted by alqimantas to php php random password ... saved by 1 person ... 0 comments ... 7 months, 2 weeks
  2. MySQL random password string

    Random string (like password).

    1 SELECT CONV(FLOOR(RAND() * 99999999999999), 10, 36);
    Posted by alqimantas to sql mysql random password ... saved by 1 person ... 0 comments ... 7 months, 2 weeks
  3. Generate random password

    A fully password generator.

     1 <?php
    2
    3 /**
    4 * Generate random password
    5 *
    6 * @param integer $length Length of the generated password
    7 * @param boolean $allow_uppercase
    8 * @param boolean $allow_lowercase
    9 * @param boolean $allow_numbers
    10 * @param boolean $allow_special
    11 * @param boolean $fix_similar If true, check if string contains mistakeable chars, add if accepted
    12 * @param string $valid_charset
    13 * @return string
    14 */
    15 function rpassword($length = 8, $allow_uppercase = 1, $allow_lowercase = 1, $allow_numbers = 1, $allow_special = 0, $fix_similar = 0, $valid_charset = "") {
    16 // Create a list of usable chars based upon the parameters
    17 if (!$valid_charset) {
    18 if ($allow_uppercase) $valid_charset .= 'ABCDEFGHIJKLMNOPQRSTUVXYZ';
    19 if ($allow_lowercase) $valid_charset .= 'abcdefghijklmnopqrstuvxyz';
    20 if ($allow_numbers) $valid_charset .= '0123456789';
    21 if ($allow_special) $valid_charset .= '!#$%&()*+-./;<=>@\_';
    22 }
    23 // Find the charset length
    24 $charset_length = strlen($valid_charset);
    25 // If no chars is allowed, return false
    26 if ($charset_length == 0) return false;
    27 // Initialize the password and loop till we have all
    28 $password = "";
    29 while(strlen($password) < $length) {
    30 // Pull out a random char
    31 $char = $valid_charset[mt_rand(0, ($charset_length-1))];
    32
    33 if (($fix_similar && !strpos('O01lI5S', $char)) || !$fix_similar) $password .= $char;
    34 }
    35
    36 return $password;
    37 }
  4. Generate random password with given length from given chars.

    Generate random password with given length from given chars.

    1 def get_random_password(self, length=6, chars='1234567890'):
    2 """
    3 Generate random password
    4 length - length of the password.
    5 chars - allowed chars
    6 """
    7 return ''.join([random.choice(chars) for i in range(length)])
    Posted by prudis to python python password ... saved by 2 persons ... 0 comments ... 1 year, 1 month
  5. Generate random password

    Simple straightforward algorithm

     1 <?php
    2
    3 function generate_random_password($length = 8)
    4 {
    5 $charset = 'qwertyuioplkjhgfdsazxcvbnm1234567890';
    6 $last_char_pos = strlen($charset) - 1;
    7
    8 $password = '';
    9
    10 for ($i = 0; $i < $length; $i++) {
    11 $char = rand(0, $last_char_pos);
    12 $password .= $charset[$char];
    13 }
    14
    15 return $password;
    16 }
    Posted by alqimantas to php generate random password ... saved by 1 person ... 0 comments ... 1 year, 1 month
showing 10, 25, 50 items per pages

Pages : 1

Flux RSS friendsnippetLatest snippets


More...