def decrypt(encrypted_data, secret_key):

    '''
        uses cryptography module to decrypt byte data
        cipher: AES (128 bit block_size)
        hash: sha512
        key size: 256 bit (first 32 bytes of secret key hash)
        vector size: 128 bit (next 16 bytes of secret key hash)
        padding: PKCS7
        cipher mode: CBC
        backend: openssl 1.0.2a
    :param encrypted_data: bytes with data to decrypt
    :param secret_key: [optional] string used to decrypt data
    :return: encrypted byte data, secret key hex string
    '''

# validate input
    if not isinstance(encrypted_data, bytes):
        raise TypeError('\nbyte data input must be byte datatype.')
    elif not isinstance(secret_key, str):
        raise TypeError('\nsecret key input must be a utf-8 encoded string.')

# retrieve cipher key and initialization vector from sha256 hash of secret key
    key_bytes = hashlib.sha512(secret_key.encode('utf-8')).digest()
    cipher_key = key_bytes[0:32]
    cipher_vector = key_bytes[32:48]

# construct decryptor
    cipher_kwargs = {
        'algorithm': algorithms.AES(cipher_key),
        'mode': modes.CBC(cipher_vector),
        'backend': openssl.backend
    }
    cipher = Cipher(**cipher_kwargs)
    decryptor = cipher.decryptor()

# decrypt and remove padding
    padded_data = decryptor.update(encrypted_data) + decryptor.finalize()
    unpadder = padding.PKCS7(128).unpadder()
    byte_data = unpadder.update(padded_data) + unpadder.finalize()

    return byte_data