def pkcs7_pad(inp, block_size):
    """
    Using the PKCS#7 padding scheme, pad <inp> to be a multiple of
    <block_size> bytes. Ruby's AES encryption pads with this scheme, but
    pycrypto doesn't support it.

    Implementation copied from pyaspora:
    https://github.com/mjnovice/pyaspora/blob/master/pyaspora/diaspora/protocol.py#L209
    """
    val = block_size - len(inp) % block_size
    if val == 0:
        return inp + (bytes([block_size]) * block_size)
    else:
        return inp + (bytes([val]) * val)