Hack Forums
[Python] Secure password generator - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [Python] Secure password generator (/showthread.php?tid=4963530)



Secure password generator - ๖ꜦȳpƎƦ SƟƱƿ - Aug 25, 2015

Code
#!/usr/bin/env python
import random
import string
import os
import time
import sys
try:
os.system('clear')
times = 0
def randomword():
   s = string.uppercase+string.digits+string.lowercase+string.punctuation
   ring = ''.join(random.sample(s,20))
   print ring
while times < 5:
  randomword()
  times += 1
  time.sleep(0.5)
except KeyboardInterrupt:
    sys.exit(0) # or 1, or whatever
This is a secure password generator, outpout:
Code
P-k8~}jsu]%+l1p6XAr_
=s;R7UFkbAfEW/S|])(:
\BMZ;<o/+dJ'!V}"f#?.
&y`oI-q/a+:\3~u)xgSF
#AJ`quLwxUN_SBV!~g&D



* - SIM-1866423 - Aug 25, 2015

You can't remember this so which is mean you must save it anywhere ... And saving ur password anywhere,uhmm? Unsecure lol.


* - Shoe - Aug 25, 2015

(Aug 25, 2015 05:02 PM)b3mb4m Wrote:  You can't remember this so which is mean you must save it anywhere ... And saving ur password anywhere,uhmm? Unsecure lol.

You're thinking secure as in "can't be stolen or keylogged" - I believe OP means as in "can't be cracked." Logically these can be cracked but not within a human life.


* - ๖ꜦȳpƎƦ SƟƱƿ - Aug 26, 2015

(Aug 25, 2015 05:02 PM)b3mb4m Wrote:  You can't remember this so which is mean you must save it anywhere ... And saving ur password anywhere,uhmm? Unsecure lol.

you can tweak the settings , remove string.punctiation and you have secure passwords but you can still remember it,


* - Introvert - Aug 26, 2015

Cool share, but your program can be written as one line of code...
PHP Code

<?php 
for s in map(lambda x: ''.join(__import__('random').sample(x, 20)), ['abcdefghijklmnopqrstuvwxyz'+'ABCDEFGHIJKLMNOPQRSTUVWXYZ'+'0123456789'+'!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~'] * 5): print s 



* - zmetra - Aug 26, 2015

(Aug 26, 2015 01:54 AM)Introvert Wrote:  Cool share, but your program can be written as one line of code...
PHP Code

<?php 
for s in map(lambda x: ''.join(__import__('random').sample(x, 20)), ['abcdefghijklmnopqrstuvwxyz'+'ABCDEFGHIJKLMNOPQRSTUVWXYZ'+'0123456789'+'!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~'] * 5): print s 

You could use an ASCII table chart to map the int representation of each character you specified and covert it to char starting from 33 to 125.
Code
for s in range(5): print ''.join(random.sample([chr(c) for c in range(33,125)], 20))

Which does the same, and no need for map, lambda, and string concatenation.


* - Goodies - Aug 26, 2015

A secure password generator would choose a random string of concatenated words.

Telephone$Mothership!

That is a secure password. It's incredibly easy to remember, incredibly entropic, and incredibly difficult to brute force.

> inb4 my accounts get locked out while people think that's my actual password


* - Introvert - Aug 27, 2015

(Aug 26, 2015 05:44 PM)zmetra Wrote:  You could use an ASCII table chart to map the int representation of each character you specified and covert it to char starting from 33 to 125.
Code
for s in range(5): print ''.join(random.sample([chr(c) for c in range(33,125)], 20))

Which does the same, and no need for map, lambda, and string concatenation.

Wow. I hadn't even thought of that! I like it.