summaryrefslogtreecommitdiff
path: root/randtest.py
blob: 67def614c6fc095df4233ae78d4b7e84425d6ff7 (plain)
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
#!/bin/python3.11
import sys
import random
import argparse
import datetime
def main():
	#argument parsing
	parg = argparse.ArgumentParser(prog='randtest',
		description='generates random butes',
		)
	parg.add_argument('-n', '--nbytes', type=int, 
		help='number of bytes to write',
		default=100)
	parg.add_argument('-f', '--file', 
		help='file name to write to',
		default='test')
	parg.add_argument('-v','--version', action='version', 
		version='randtest for Python 3.11.3',
		help='Version Info')
	args = parg.parse_args()

	fname = args.file
	nbytes = args.nbytes
	
	#random
	random.seed(datetime.datetime.now().microsecond)

	#file open in byte mode
	f = open(fname, 'wb')
	#write the file
	f.write(random.randbytes(nbytes))
	#close the file
	f.close()

main()