Python [python] How can I get my OS to pick this up as entropy?

AI Thread Summary
The discussion revolves around creating a script in Python to generate random keys. The user shares a code snippet that utilizes the `random`, `string`, and `time` libraries to produce random strings and words from a dictionary file. The script includes an infinite loop and employs various randomization techniques to enhance the randomness of the output. The user seeks advice on modifying the script to simulate a typing effect instead of just printing the output directly. The conversation highlights the importance of randomness in key generation and the potential for further improvements in the script's functionality.
Alexi-dono
Messages
13
Reaction score
1
So I am going to be making some keys; and I want to make them more random... So I made this:

#I know that the code is pretty crude, but it works.
#P.S. it is an infinite loop, run at your own risk
import random
from random import randint
import string
import time
x=1
n=randint(5,90)
t=randint(20,1000)
s=randint(404,700)
char_set = string.ascii_uppercase + string.lowercase + string.digits + string.whitespace + string.punctuation
words = [line.strip() for line in open('/etc/dictionaries-common/words')]
while x>0:
a=randint(1,2)
r=a
b=randint(1,2)
k=b​
if b>1:
time.sleep(t/s)​
if r>0:
print ''.join(random.sample(char_set*s, n))
time.sleep(t/s/t)​
if r>1:
print(random.choice(words))
time.sleep(t/s/t)​
 
Last edited:
Technology news on Phys.org
I figured it out...
 
Just out of curiosity, which language was this in?

And if you don't mind telling us what the solution was, maybe other people can benefit from it. :oldsmile:
 
python, my semi-solution was to save the file and do this: "python filename > output_filename". i now need to find a way for it to imitate a typing stream; instead of a simple output. Any suggestions?

finished script:
import random
from random import randint
import string
import time
x=1
n=randint(5,90)
t=randint(200,5000)
s=randint(404,700)
char_set = string.ascii_uppercase + string.lowercase + string.digits + string.whitespace + string.punctuation
words = [line.strip() for line in open('/etc/dictionaries-common/words')]
while x>0:
a=randint(1,2)
r=a
b=randint(1,2)
k=b
if b>1:
time.sleep(t/1000)
if r>0:
print ''.join(random.sample(char_set*s, n))
time.sleep(t/s/t)

if r>1:
print(random.choice(words))
time.sleep(t/s/t)
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I have a quick questions. I am going through a book on C programming on my own. Afterwards, I plan to go through something call data structures and algorithms on my own also in C. I also need to learn C++, Matlab and for personal interest Haskell. For the two topic of data structures and algorithms, I understand there are standard ones across all programming languages. After learning it through C, what would be the biggest issue when trying to implement the same data...
Back
Top