BOBOBK

Python Random Strong Password Generator

MISCELLANEOUS

Due to security needs, it is recommended that users use different strong passwords on different websites. Setting a strong password every time can be troublesome, so here we write a small Python program to generate strong passwords. In the future, just visit the following website and copy-paste the password.

Python code as follows

import random
def get_strong_pass():
	strongpassword=""
	for i in range(16):
		strongpassword += random.choice('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_')
	return strongpassword
get_strong_pass()

Next, just call this function inside Django. Here I integrated the code into WordPress, so when visiting this page, you can see the just-generated strong password at the bottom.

JavaScript code


<script>
function createPassword(min,max) {
        // Arrays used for generating random passwords
        var num = ["0","1","2","3","4","5","6","7","8","9"];
        var english = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"];
        var ENGLISH = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"];
        var special = ["-","_","#"];
        var config = num.concat(english).concat(ENGLISH).concat(special);

        // Ensure at least one from each group exists
        var arr = [];
        arr.push(getOne(num));
        arr.push(getOne(english));
        arr.push(getOne(ENGLISH));
        arr.push(getOne(special));

        // Get the desired password length
        var len = min + Math.floor(Math.random()*(max-min+1));

        for(var i=4; i<len; i++){
            // Pick a random character from the config array
            arr.push(config[Math.floor(Math.random()*config.length)]);
        }

        // Shuffle the array
        var newArr = [];
        for(var j=0; j<len; j++){
            newArr.push(arr.splice(Math.random()*arr.length,1)[0]);
        }

        // Randomly pick one value from an array
        function getOne(arr) {
            return arr[Math.floor(Math.random()*arr.length)];
        }

        return newArr.join("");
    }
document.write(createPassword(15,15));
</script>

Strong password is here

Related

Recursively download files python

TECHNOLOGY
Recursively download files python

I want to back up my website recently, but the size of the file downloaded by PHP is limited, and I am too lazy to install FTP to download it. So I thought of temporarily setting up a secondary domain name site, and then using python (python3)'s requests library to directly download all the files and folders in the root directory of the website to achieve the purpose of backup.

Introduction to Artificial Neural Networks

TECHNOLOGY
Introduction to Artificial Neural Networks

Artificial Neural Network (ANN), also called Neural Network (NN) or neural-like network, is a mathematical model that mimics the structure and function of biological neural networks. It consists of a large number of neurons connected for computation. In most cases, artificial neural networks can change their internal structure based on external information, making them adaptive systems, simply put, they have learning capabilities.