-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathrandomnes.py
More file actions
35 lines (29 loc) · 828 Bytes
/
randomnes.py
File metadata and controls
35 lines (29 loc) · 828 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/python
import time
rangeInt = 1024 * 1024
rangeIntTmp = raw_input("How many bytes (enter for 1 MB):")
if rangeIntTmp != '':
rangeInt = int(rangeIntTmp)
targetFile = "/dev/null"
print "FULLPATH to target file"
print "be careful! overwrites existing files without warning!"
targetFileTmp = raw_input("(just enter for '/dev/null'): ")
if targetFileTmp != "":
targetFile = targetFileTmp
fRandom = open("/dev/urandom", "r")
fTarget = open(targetFile, "w")
timerStart = time.time()
try:
for i in range(rangeInt):
# Do stuff with byte.
byte = fRandom.read(1)
fTarget.write(byte)
# !DANGEROUS! Could interact with console!
#print str(byte)
except Exception, e:
print "Error: ", str(e)
finally:
fRandom.close()
fTarget.close()
print "########### fin"
print "duration: " + str(time.time() - timerStart)