def pkcs7_pad(inp, block_size):
val = block_size - len(inp) % block_size<EOL>if val == <NUM_LIT:0>:<EOL><INDENT>return inp + (bytes([block_size]) * block_size)<EOL><DEDENT>else:<EOL><INDENT>return inp + (bytes([val]) * val)<EOL><DEDENT>
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