code: def convert_hexstr_to_bigbase(hexstr, alphabet=ALPHABET, bigbase=BIGBASE):
      r
      x = int(hexstr, 16)  # first convert to base 16
      if x == 0:
          return '0'
      sign = 1 if x > 0 else -1
      x *= sign
      digits = []
      while x:
          digits.append(alphabet[x % bigbase])
          x //= bigbase
      if sign < 0:
          digits.append('-')
          digits.reverse()
      newbase_str = ''.join(digits)
      return newbase_str
docs: r"""
      Packs a long hexstr into a shorter length string with a larger base
  
      Ignore:
          # Determine the length savings with lossless conversion
          import sympy as sy
          consts = dict(hexbase=16, hexlen=256, bigbase=27)
          symbols = sy.symbols('hexbase, hexlen, bigbase, newlen')
          haexbase, hexlen, bigbase, newlen = symbols
          eqn = sy.Eq(16 ** hexlen,  bigbase ** newlen)
          newlen_ans = sy.solve(eqn, newlen)[0].subs(consts).evalf()
          print('newlen_ans = %r' % (newlen_ans,))
  
          # for a 27 char alphabet we can get 216
          print('Required length for lossless conversion len2 = %r' % (len2,))
  
          def info(base, len):
              bits = base ** len
              print('base = %r' % (base,))
              print('len = %r' % (len,))
              print('bits = %r' % (bits,))
          info(16, 256)
          info(27, 16)
          info(27, 64)
          info(27, 216)