From 9a770e18011c59d90c17147d7d49205ed7a1ea9a Mon Sep 17 00:00:00 2001 From: Minimons Date: Fri, 24 Jul 2026 15:23:01 +0200 Subject: [PATCH] X: Add 'cleanupPrivateKeyFile.sh' --- cleanupPrivateKeyFile.sh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100755 cleanupPrivateKeyFile.sh diff --git a/cleanupPrivateKeyFile.sh b/cleanupPrivateKeyFile.sh new file mode 100755 index 0000000..56f622f --- /dev/null +++ b/cleanupPrivateKeyFile.sh @@ -0,0 +1,20 @@ +python3 -c ' +import json +import sys + +source, destination = sys.argv[1], sys.argv[2] + +with open(source) as f: + key = json.load(f) + +if len(key) not in (32, 64): + raise SystemExit(f"Unexpected key length: {len(key)}") + +if not all(isinstance(value, int) and 0 <= value <= 255 for value in key): + raise SystemExit("The file contains invalid byte values") + +with open(destination, "w") as f: + f.write(json.dumps(key, separators=(",", ":"))) + +print(f"Created {destination} with {len(key)} bytes") +' $1 $2 \ No newline at end of file