Python is a simple way to generate 8 bit random passwords

  • 2020-06-01 10:20:20
  • OfStack

This example demonstrates how Python can simply generate 8-bit random passwords. I will share it with you for your reference as follows:


#!/usr/bin/env python
# -*- coding: utf-8 -*-
import random
import string
# The first 1 methods 
seed = "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*()_+=-"
sa = []
for i in range(8):
  sa.append(random.choice(seed))
salt = ''.join(sa)
print salt
# The first 2 methods 
salt = ''.join(random.sample(string.ascii_letters + string.digits, 8))
print salt

PS: here are two related online tools for your reference:

Online random number/string generation tool:
http://tools.ofstack.com/aideddesign/suijishu

High strength password generator:
http://tools.ofstack.com/password/CreateStrongPassword

For more information about Python, please check out the topics on this site: Python data structure and algorithm tutorial, Python Socket programming skills summary, Python function skills summary, Python string manipulation skills summary, Python introduction and advanced classic tutorial and Python file and directory manipulation skills summary.

I hope this article has been helpful to you in Python programming.


Related articles: