How to compare binary signals with different lengths
you need to elaborate on what you mean by similarity because there are many possibilities.

If you key sequence is embedded in any of your test sequences, the cross correlation is as was suggested by one of the commentators is a good approach, which forms a point by point product between the test and key sequence and sums the results of the product and provides a number, which if the key has $n$ ones the sum of products equal to $n$ indicates an exact match.  The key sequence is shifted relative to the test and the sum of products is calculated for all possible shifts.  This also works for situations where there are error bits in the tested sequence, when the sum product is near $n$.

One might presume that a sum product equal to zero is an indication of dissimilarity, and could be depending on your application but it is usually preferable that measures of similarity should be invariant under information preserving transformations of the data. The replacement of each one by a zero is an information preserving transformation, so a cross correlation value near zero in this case should be considered to be very similar.

A reverse ordering of test sequences is another information preserving transformations.  

It is usual to consider dissimilarity as a situation where  a one in the reference would correspond to either a one or zero in the other. In this case dissimilarity to equivalent to statistical independence.

It is sometimes useful to transform $(0,1)$ to $(-1,1)$ when calculating cross correlation.  

You can also compare sequences by the ratio of ones to zeros. Run length statistics are also useful.  

Cross correlation is compatible with statistical hypothesis testing and confidence bounds. These calculations are covered in any good calculus level statistics text book (like Bhattacharyya and Johnson)