     
     class open func canUnlock(data: Data, password: String) -> Bool {
         return autoreleasepool { () -> Bool in
-            let dataProvider = CGDataProvider(data: data as CFData)
-            let pdf = CGPDFDocument(dataProvider!)
+            let pdf = CGPDFDocument(CGDataProvider(data: data as CFData)!)
             
             // Try a blank password first, per Apple's Quartz PDF example
             if pdf?.isEncrypted == true &&

        
        guard password != nil else { return pdf }
        
        return autoreleasepool { () -> CGPDFDocument? in
            // Try a blank password first, per Apple's Quartz PDF example
            if pdf.isEncrypted == true &&
                pdf.unlockWithPassword("") == false {
                if let pwd = password {
                    // Nope, now let's try the provided password to unlock the PDF
                    if let cPasswordString = pwd.cString(using: String.Encoding.utf8) {
                        if pdf.unlockWithPassword(cPasswordString) == true {
                            return pdf
                        }
                    }
                }
            }
            return nil
        }
    }
    
    class open func convertPdfToData(pdf: CGPDFDocument, password: String? = nil) throws -> Data {
        let data = NSMutableData()
        
        autoreleasepool {

        return data as Data
    }
    
    class open func addPassword(fileURL: URL, password: String) -> Data? {
        do {
            return addPassword(data: try Data(contentsOf: fileURL), password: password)
        } catch {
            return nil
        }
    }
    
    class open func addPassword(data: Data, password: String) -> Data? {
        if let provider = CGDataProvider(data: data as CFData) {
            if let pdf = CGPDFDocument(provider) {
                return convertPdfToData(pdf: pdf, password: password)
            }
        }
        return nil
    }
    
    class open func removePassword(fileURL: URL, password: String) throws -> Data? {
        return try removePassword(data: try Data(contentsOf: fileURL), password: password)
    }
    
    class open func removePassword(data: Data, password: String) throws -> Data? {
        if let pdf = unlock(data: data, password: password) {
            return convertPdfToData(pdf: pdf)
        }
        return nil
    }
    
    class open func convertPDFToImages(fileURL: URL, password: String? = nil) throws -> [UIImage]? {
        return try convertPDFToImages(data: try Data(contentsOf: fileURL), password: password)
    }
    
    class open func convertPDFToImages(data: Data, password: String? = nil) throws -> [UIImage]? {
        if let provider = CGDataProvider(data: data as CFData) {
            if let pdf = CGPDFDocument(provider) {
                return convertPDFToImages(pdf: pdf, password: password)
            }
        }
        return nil
    }
    
    class open func convertPDFToImages(pdf: CGPDFDocument, password: String? = nil) -> [UIImage]? {
