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)
 
Thread 'Is this public key encryption?'
I've tried to intuit public key encryption but never quite managed. But this seems to wrap it up in a bow. This seems to be a very elegant way of transmitting a message publicly that only the sender and receiver can decipher. Is this how PKE works? No, it cant be. In the above case, the requester knows the target's "secret" key - because they have his ID, and therefore knows his birthdate.
Thread 'Project Documentation'
Trying to package up a small bank account manager project that I have been tempering on for a while. One that is certainly worth something to me. Although I have created methods to whip up quick documents with all fields and properties. I would like something better to reference in order to express the mechanical functions. It is unclear to me about any standardized format for code documentation that exists. I have tried object orientated diagrams with shapes to try and express the...
Back
Top