From cc3eed896e039d3c7088454ed49e483b82fe9917 Mon Sep 17 00:00:00 2001 From: Alejandro Soto Date: Wed, 22 May 2024 14:59:49 -0600 Subject: scripts/makehex: initial commit --- scripts/makehex.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 scripts/makehex.py (limited to 'scripts/makehex.py') diff --git a/scripts/makehex.py b/scripts/makehex.py new file mode 100644 index 0000000..3304fb3 --- /dev/null +++ b/scripts/makehex.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python3 +# +# This is free and unencumbered software released into the public domain. +# +# Anyone is free to copy, modify, publish, use, compile, sell, or +# distribute this software, either in source code form or as a compiled +# binary, for any purpose, commercial or non-commercial, and by any +# means. + +import sys + +bindata = sys.stdin.buffer.read() +assert len(bindata) % 4 == 0 +nwords = len(bindata) // 4 + +for i in range(nwords): + if i < len(bindata) // 4: + w = bindata[4*i : 4*i+4] + print("%02x%02x%02x%02x" % (w[3], w[2], w[1], w[0])) + else: + print("0") + -- cgit v1.2.3