#!/bin/env python # # BeautifulSoup is required inorder for this software to run smoothly. # one can either compile BeautifulSoup v3 or v4 from python source from # this following site: http://www.crummy.com/software/BeautifulSoup/ # On windows after source package has been extracted, at a command prompt # python setup.py install # or # install the binary file via an installer. # I would need to figure out a way to detect whether a user has this package # installed or not one of these days. # # http://www.random.org/decimal-fractions/?num=100&dec=20&col=1&format=html&rnd=new # http://www.random.org/decimal-fractions/?num=key1&dec=key28&col=1&format=html&rnd=new # # An improved version of locating a random password. # Pulling a random number from random.org by parsing its webpage. # ################################################################################### author = 'YXNjaGVuYmFjaEBnbWFpbC5jb20=' import base64 def askForInputs(): a,b = 0,0 k1 = raw_input("Please enter a value less than 10000 ? ") k2 = raw_input("Please enter an amount up to 20 ? ") if k1.isdigit() and k2.isdigit(): if int(k1) <= 10000 and int(k2) <= 20: a = int(k1) b = int(k2) setWebValues(a, b) else: print "Your numbers are out of bound. Please try again. " else: print "Inputs are not digits, Please try again. " def setWebValues(key1, key2): import requests import sys try: from BeautifulSoup import BeautifulSoup except ImportError: from bs4 import BeautifulSoup s = requests.Session() payload = {"num":key1, "dec":key2, "col":"1", "format":"html", "rnd":"new"} r = s.get("http://www.random.org/decimal-fractions/", params=payload) page = BeautifulSoup(r.content) # i think i fixed this networking connection issue on linux. if sys.platform == "win32": r.connection.close() setRandomNum(page, key2) def setRandomNum(wp, key2): import random import decimal from decimal import getcontext decimal.getcontext().prec = key2 c="" z = wp.find('pre') try: for a in z: c=c+a except TypeError as err: print "error message: " print err print "Random.org won't allow too many data transfers between your machine and their server. " print "Therefore, you have reached your daily dose of data transfer to random.org. Try again tomorrow." c = c.encode('ascii') d = c.split("\n") print d[10] d.pop() mn = decimal.Decimal(d[random.randint(0,len(d)-1)]) print mn findMagicPassword(mn) def findMagicPassword(magNum): import string import random # see Ma, no random.seed(time.time()) ! random.seed(magNum) mess = "" mess = string.digits mess = mess + string.ascii_uppercase mess = mess + string.ascii_lowercase # no punctuations are included in this passcode. letterList = [] for i in mess: letterList.append(i) word, pword = "", "" a, tmp =0,0 # now it will generate 10 passwords for you to view for x in range(10): while a < 10: # By changing the 10 to a 15, the password will become longer tmp = random.randint(0, len(letterList)-1) letter = str(letterList[tmp]) pword = pword + letter a=a+1 print "Password is: " + pword a=0 pword="" def main(): import sys askForInputs() sys.exit() main()