Generate Hamming codes
JavaScript (ES6), 116 bytes

f=(a,p=i=0)=&gt;1/a[p]?f(a,p+p+1,a.splice(p,0,0)):[...Array(p)].map(_=&gt;i&amp;++i?~~a[i-1]:a.reduce((p,e,j)=&gt;p^=++j&amp;i&amp;&amp;e,0))


If the padding is unnecessary, then for 97 bytes:

f=(a,p=i=0)=&gt;1/a[p]?f(a,p+p+1,a.splice(p,0,0)):a.map(e=&gt;i&amp;++i?e:a.reduce((p,e,j)=&gt;p^=++j&amp;i&amp;&amp;e,0))