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.
I tried a web search "the loss of programming ", and found an article saying that all aspects of writing, developing, and testing software programs will one day all be handled through artificial intelligence. One must wonder then, who is responsible. WHO is responsible for any problems, bugs, deficiencies, or whatever malfunctions which the programs make their users endure? Things may work wrong however the "wrong" happens. AI needs to fix the problems for the users. Any way to...
Back
Top