/ PHP

Previous Article

PHP function to generate a random password

Next Article

This simple function generates a random password using all alphanumeric characters. While this won't be the most secure password, it is better than a dictionary word. The function accepts an integer to determine the password length, but if one isn't passed defaults to 16.

function password_generator($length = 16)
{
    $str = 'abcdefghijkmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';
    for ($i = 0, $password = ''; $i < $length; $i++) {
        $password .= substr($str, mt_rand(0, strlen($str) - 1), 1);
    }
    return $password;
}
Avatar of Clive Walkden

Clive Walkden

Latest Articles

Linux command line tools, installations etc

Linux

Terraform Installation

A quick installation guide for Terraform on Ubuntu 18.04

Bitcoin - Cryptocurrency not just for geeks

Bitcoin

RollerCoin Intro

An introduction to the RollerCoin site and how you can use it to mine your own coins

Magento 2 Blog Posts

Magento 2

Magento 2.4.x Writing to a Log File

How to log to information to a file in different Magento 2.4.x versions