logo
down
shadow

generate a random password and update the database


generate a random password and update the database

Content Index :

generate a random password and update the database
Tag : php , By : kameel
Date : November 27 2020, 04:01 AM

I hope this helps you . I have to update the passwords for all of the existing users with random unique password. I have about 4000 users using SQL SERVER.
// 1. Don't declare functions inside loops. Functions should generally only ever be declared
//    in either the global scope, or a class definition.
function generatePassword ($length = 8) {
    $password = '';
    $chars = array_merge(range('a', 'z'), range('A', 'Z'), range(0, 9));
    for ($i = 0; $i < $length; $i ++) {
        $password .= $chars[array_rand($chars)];
    }
    return $password;
} 

$userSQL = "SELECT a002UserID FROM tbl002password WHERE a002UserID LIKE 'non%'";
$userrs  = $db->query($userSQL);

$userList1 = array();
while($row = $userrs->fetch(PDO::FETCH_OBJ)) {
    $userList1[] = $row->a002UserID;
}

// 2. Preparing statements like this increase performance as they are only parsed _once_,
//    but executed many times.
$insertPass = $db->prepare("UPDATE tbl002password SET a002password = ? WHERE a002UserID = ?");
foreach($userList1 as $uid) {
    $pass_gen = generate_password();
    $insertPass->execute([$pass_gen, $uid]);
    echo "updated $uid";
}

Comments
No Comments Right Now !

Boards Message :
You Must Login Or Sign Up to Add Your Comments .

Share : facebook icon twitter icon

How to generate random password, or temporary URL, for resetting password in Zend Framework?


Tag : zend-framework , By : Brownell
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , Zend Framework does not have a password-generating class. Here's an article on how to use the PEAR module Text_Password to generate a password: https://web.archive.org/web/1/http://blogs.techrepublic%2ecom%2ecom/howdoi/?p=118
However, it's not a good security practice to send the password in a plain email. Instead, you should reset their account so they can temporarily log in without giving a password (given an expiring URL you send them in the email), and once they log in, require them to update their own password to something they know. Then store the salted hash of their password.

Any Idea how I generate random Char values in Java? I'm creating a random password generator


Tag : java , By : niel
Date : March 29 2020, 07:55 AM
like below fixes the issue I'm creating a random password generator in java and need some help with how I can generate random char values in the program. Any ideas? I'm using a menu system as a way to show different types of passwords to generate like lowercase, uppercase, etc.
Random r = new Random();

String alphabet = "123xyz";

// Prints 50 random characters from alphabet
for (int i = 0; i < 50; i++) 
{
    System.out.println(alphabet.charAt(r.nextInt(alphabet.length())));
} 

Generate Random Password which meets Active Directory Password Policy Complexity Requirements Programmatically


Tag : chash , By : OlioEngr
Date : March 29 2020, 07:55 AM
Hope this helps See if something like this works for you. I originally wrote this for .Net Identity 2 but it should point you in the right direction. You can see how I'm using it on GitHub
var validator = new PasswordValidator
{
    RequiredLength = 6,
    RequireNonLetterOrDigit = false,
    RequireDigit = true,
    RequireLowercase = true,
    RequireUppercase = true
};

passwords.Add(GeneratePassword(validator));


private static string GeneratePassword(PasswordValidator passwordValidator)
{
    var rnd = new Random();

    while (true)
    {
        var password = Membership.GeneratePassword(passwordValidator.RequiredLength, 0);
        if ((passwordValidator.RequireDigit && !password.Any(char.IsDigit)) || (passwordValidator.RequireLowercase && !password.Any(char.IsLower)) || (passwordValidator.RequireUppercase && !password.Any(char.IsUpper)))
            continue;

        if (!passwordValidator.RequireNonLetterOrDigit) password = Regex.Replace(password, @"[^a-zA-Z0-9]", m => rnd.Next(0, 10).ToString());
        return password;
    }
}

Wordpress - generate random unique number using atomic operation and update database


Tag : php , By : Eniac
Date : March 29 2020, 07:55 AM
may help you . I managed to get it working by creating two functions. One responsible for getting all the available numbers from within the wp_tickets table where used = 0 and lottery_id = $postID which returns a single random number from the available tickets numbers.
The second function is then responsible for updating the wp_tickets table with the ticket number generated from the get_available_numbers function.
function get_available_numbers($postID) {
            global $wpdb;
                $result = $wpdb->get_results(
                    "
                    SELECT ticket_number
                    FROM wp_tickets
                    WHERE lottery_id = ".$postID." AND used = 0
                    ORDER BY RAND()
                    LIMIT 1
                    "
                    );
            return $result[0]->ticket_number;
}


function add_ticket_number($postID, $order_id, $number, $user_id) {
        global $wpdb;

        $wpdb->query(
            "
            UPDATE wp_tickets
            SET used = 1, order_id = ".$order_id.", user_id = ".$user_id."
            WHERE ticket_number= ".$number." AND lottery_id = ".$postID." AND used = 0
            "
                    );
}


for ( $i = 0; $i < $item_meta['_qty'][0]; $i++ ) {
                        $number = $this->get_available_numbers($product_id);
                        $this->add_ticket_number($product_id, $order_id, $number, $order->get_user_id());
                    }
function add_ticket_number($postID, $order_id, $user_id) {
        global $wpdb;

        $wpdb->query(
            "
            UPDATE wp_tickets
            SET used = 1, order_id = ".$order_id.", user_id = ".$user_id."
            WHERE lottery_id = ".$postID." AND used = 0
                        ORDER BY RAND()
                        LIMIT 1
            "
                    );
}

how to show password in asterik format when we generate random password


Tag : chash , By : Philofax
Date : March 29 2020, 07:55 AM
Related Posts Related QUESTIONS :
  • Laravel email configuration: what am I missing?
  • Assign indexed array values to multidimensional array?
  • Custom WordPress stylesheet not loading
  • Data attribute only returning first value
  • How to list all roles with Permissions,in spatie permission Package?
  • How to achieve this number pattern with n input
  • How to iterate array inside array data in laravel ,output are given below
  • To get output of movie with its genre
  • Extracting some data from a JS object literal string in PHP using Regex
  • axios and vuex are deleting wrong index in array
  • Setting empty CURLOPT_POSTFIELDS
  • Laravel 5.8 use subdomain as API endpoint beside domain.com/api
  • Error while add data in database SQL Server 2016
  • Does PhpStorm allow to skip PHPDoc tags when type hints is declared?
  • html classes are changed to Attributes
  • Using json to import multidimensional data
  • passing data from the view to the controller, where the data comes from another controller
  • How to extract integer and decimal numbers in PHP string correctly?
  • Parsing Sub-Object from an XML Feed with objects
  • Getting error "Unknown column 'text' in 'field list'"
  • How to properly get onedrive access token via php and curl
  • How to add spell check to a php function
  • Is it posible to create css rules with php?
  • Pretty URL with $_GET method
  • Wordpress always load same page - index.php
  • Find value in array and return with new from different array
  • PHP multiple file upload with different keys
  • Can't modify times one a time without weird errors
  • Get size of scraped image with domcrawler (Goutte)
  • Laravel - Ordering a collection of models
  • PHP Fatal error: Uncaught Error: Call to a member function setFetchMode() on boolean
  • Strict Standards: Only variables should be passed by reference in /main_dir/sub_dir/backup.php
  • Uncaught Google_Exception: (update) unknown parameter: 'copyRequiresWriterPermission'
  • Laravel 5 form does not redirect with old input
  • How to get values greater than or equal to in Mysql database sql when its a value like 1:00 PM?
  • PHP datediff overday issue
  • Masking an auto incrementing primary key
  • How to grab a String BEFORE a certain word
  • ZF2 Routing Multiple Controllers based on route constraints
  • How to deregister/dequeue jquery.sticky.js in Elementor (Pro)?
  • How to fix errors counting words in text plain with PHP?
  • How to get View data in Laravel in custom helper or directive
  • Creating a new data entry into a database with eloquent and trying to access the variable in the url
  • How to test authentication using Laravel Dusk?
  • PHP parse_str not getting all $_GET variables
  • Variable issues in php class
  • Get orders between dates in Codeigniter
  • Eloquent Special Chars Issue
  • Keeping leading zeros column Mysql
  • Current level navigation in Wordpress
  • Add a custom text to WooCommerce cart items if the product has a specific shipping class
  • Error connecting to CommissionJunction Token : [60] SSL certificate problem: unable to get local issuer certificate
  • How do I add a new key value pair to an object in PHP?
  • Http post request to php with dart
  • How to add a route in with blade into parameters of a component
  • How can i get the source of a 777 - CHMOD php file?
  • Convert 2010-04-16 16:30:00 to "Tomorrow Afternoon"
  • How can I hide a $_GET variable to be more secured in PHP?
  • Login to Gmail Inbox using Curl?
  • Upload Excel or CSV file to MySQL with PHP
  • shadow
    Privacy Policy - Terms - Contact Us © scrbit.com