#!/usr/bin/env python3 ############################################### # First argument is the value to be encoded, # # second argument is the name of the variable # # to be used. # ############################################### import sys import os inString = str(sys.argv[1]); print("static const char {0}[{1}] = {{ ".format(sys.argv[2], len(inString)), end='') for letter in inString[:-1]: p = ord(letter) print("{0:#x}, ".format(p), end='') p = ord(inString[-1]) print("{0:#x} ".format(int(p)), end='') print("};") print("static const uint8_t {0}_len = {1};".format(sys.argv[2], len(inString)))