blob: 14a6c970244fd68ca92e79ecd9a5cac84aeecd6d (
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
|
#!/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')
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()
|