MATL, 917 bytes
&mB&m2Gt&mBwY)!8e!XB
Takes input as string, then encoderTry it online!
&m % 1-based index of first input in second
B % convert from decimal to binary. Produces a logical vector
! % transpose
8e % reshape into matrix of columns of length 8, padding end with zeros.
! % transpose
XB % convert from binary to decimal
% (implicit) convert to string and display
Of note, B returns a matrix with the binary strings as rows, so they are automatically padded to the same length.
MATL, 9 bytes
&mB!8e!XB
Takes input as string, then encoder
&m % 1-based index of first input in second
B % convert from decimal to binary. Produces a logical vector
! % transpose
8e % reshape into matrix of columns of length 8, padding end with zeros.
! % transpose
XB % convert from binary to decimal
% (implicit) convert to string and display
Of note, B returns a matrix with the binary strings as rows, so they are automatically padded to the same length.
MATL, 17 bytes
&m2Gt&mBwY)!8e!XB
Of note, B returns a matrix with the binary strings as rows, so they are automatically padded to the same length.
MATL, 9 bytes
&mB!8e!XB
Takes input as string, then encoder
&m % 1-based index of first input in second
B % convert from decimal to binary. Produces a logical vector
! % transpose
8e % reshape into matrix of columns of length 8, padding end with zeros.
! % transpose
XB % convert from binary to decimal
% (implicit) convert to string and display
Of note, B returns a matrix with the binary strings as rows, so they are automatically padded to the same length.
MATL, 9 bytes
&mB!8e!XB
Takes input as string, then encoder
&m % 1-based index of first input in second
B % convert from decimal to binary. Produces a logical vector
! % transpose
8e % reshape into matrix of columns of length 8, padding end with zeros.
! % transpose
XB % convert from binary to decimal
% (implicit) convert to string and display
MATL, 9 bytes
&mB!8e!XB
Takes input as string, then encoder
&m % 1-based index of first input in second
B % convert from decimal to binary. Produces a logical vector
! % transpose
8e % reshape into matrix of columns of length 8, padding end with zeros.
! % transpose
XB % convert from binary to decimal
% (implicit) convert to string and display
Of note, B returns a matrix with the binary strings as rows, so they are automatically padded to the same length.
MATL, 9 bytes
&mB!8e!XB
Takes input as string, then encoder
&m % 1-based index of first input in second
B % convert from decimal to binary. Produces a logical vector
! % transpose
8e % reshape into matrix of columns of length 8, padding end with zeros.
! % transpose
XB % convert from binary to decimal
% (implicit) convert to string and display