/* Encodes input (uint32_t) into output (uint8_t). Assumes len is a multiple of 4.  */
static void ICACHE_FLASH_ATTR Encode(uint8_t *output, uint32_t *input, uint32_t len)
/* Encodes input (uint32_t) into output (uint8_t). Assumes len is a multiple of 4.  */
static void ICACHE_FLASH_ATTR Encode(uint8_t *output, uint32_t *input, uint32_t len)
{
    uint32_t i, j;
    for (i = 0, j = 0; j < len; i++, j += 4) 
    {
        output[j] = (uint8_t)(input[i] & 0xff);
        output[j+1] = (uint8_t)((input[i] >> 8) & 0xff);
        output[j+2] = (uint8_t)((input[i] >> 16) & 0xff);
        output[j+3] = (uint8_t)((input[i] >> 24) & 0xff);
    }
}