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

Click For Summary

Discussion Overview

The discussion revolves around generating random keys in Python and enhancing randomness by utilizing system entropy. Participants explore methods to improve the randomness of key generation and seek solutions for outputting the generated keys in a manner that mimics a typing stream.

Discussion Character

  • Technical explanation
  • Exploratory
  • Homework-related

Main Points Raised

  • One participant shares a Python script aimed at generating random keys using various character sets and random delays.
  • Another participant inquires about the programming language used and encourages sharing the solution for the benefit of others.
  • The original poster mentions a semi-solution involving redirecting output to a file and expresses a need to simulate a typing stream for the output.
  • The finished script is presented with modifications to the random delay and output methods, but further refinement is sought.

Areas of Agreement / Disagreement

Participants do not reach a consensus on the best method for outputting the generated keys as a typing stream, indicating ongoing exploration and differing approaches.

Contextual Notes

The discussion includes assumptions about the effectiveness of the random key generation method and the need for further refinement in output techniques. Specific dependencies on system entropy and the randomness of the Python random module are not fully addressed.

Who May Find This Useful

Readers interested in programming, particularly in Python, and those looking to enhance randomness in key generation or output methods may find this discussion relevant.

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)
 

Similar threads

  • · Replies 6 ·
Replies
6
Views
6K
Replies
1
Views
2K
  • · Replies 5 ·
Replies
5
Views
3K