Encode the column cipher
MATL, 4 bytes

e!1e


Try it online!

This is about as straightforward as possible. e is a builtin that reshapes a matrix into n rows. So we read in input1 as a string, and shape into a matrix with input2 rows:

Hl r!
eowl 
l,od 


Then, we transpose it to get this:

Hel
lo,
 wo
rld
!  


After that, we just call 1e to reshape it into a single row, and display it as a string.

As you can see in this sample program, the "reshape" function conveniently adds as many zeroes as necessary for the matrix to be a perfect rectangle. When displaying as a string, MATL treats '0's as spaces, so this automatically fills in the necessary number of spaces for no extra work.