def pad_pw(pw, pad_length):
    """Pad pw to a pad_length, so that it hides the length of the password in bytes."""
    assert 0 < pad_length < 256
    pw = bytes(pw)
    k = len(pw)/pad_length
    topad = pw[k*pad_length:]
    topad_len = pad_length - len(topad)
    if topad_len == 0:
        topad_len = pad_length
    pad = chr(topad_len) * topad_len
    return pw + pad
    # padder = padding.PKCS7(pad_length*8).padder()
    # return padder.update(bytes(pw)) + padder.finalize()