1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
RIOT/dist/tools/randhex/randhex.py
Sören Tempel 1e52ac21e4 tools: add tool for generating random hexadecimal values
This tool generates a random hexadecimal value of a given maximum size.
This is useful for generating random canary values during compile-time
for the ssp module which currently uses a constant value.
2020-01-20 14:51:26 +01:00

21 lines
422 B
Python
Executable File

#!/usr/bin/env python3
#
# Copyright (C) 2020 Sören Tempel <tempel@uni-bremen.de>
#
# This file is subject to the terms and conditions of the GNU Lesser
# General Public License v2.1. See the file LICENSE in the top level
# directory for more details.
#
import sys
import secrets
if len(sys.argv) >= 2:
maxbits = int(sys.argv[1])
else:
maxbits = 64
maxval = 2 ** maxbits
print(hex(secrets.randbelow(maxval)))