def pkcs7_unpad(data):
    """
    Remove the padding bytes that were added at point of encryption.

    Implementation copied from pyaspora:
    https://github.com/mjnovice/pyaspora/blob/master/pyaspora/diaspora/protocol.py#L209
    """
    if isinstance(data, str):
        return data[0:-ord(data[-1])]
    else:
        return data[0:-data[-1]]