code: function fillTemplate(message, template) {
      var blocks = new Buffer(template.data_len);
      blocks.fill(0);
  
      if (template.version < 10) {
          message = message.data1;
      } else if (template.version < 27) {
          message = message.data10;
      } else {
          message = message.data27;
      }
  
      var len = message.length;
  
      for (var i = 0; i < len; i += 8) {
          var b = 0;
          for (var j = 0; j < 8; j++) {
              b = (b << 1) | (message[i + j] ? 1 : 0);
          }
          blocks[i / 8] = b;
      }
  
      var pad = 236;
      for (var i = Math.ceil((len + 4) / 8); i < blocks.length; i++) {
          blocks[i] = pad;
          pad = (pad == 236) ? 17 : 236;
      }
  
      var offset = 0;
      template.blocks = template.blocks.map(function(n) {
          var b = blocks.slice(offset, offset + n);
          offset += n;
          template.ec.push(calculateEC(b, template.ec_len));
          return b;
      });
  
      return template;
  }
docs: {{{1 Fill template