blob: 1be410edd625cd4656556b58a2262046b29f5af8 (
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
|
#!/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()
|