This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let pdfData = try Data(contentsOf: URL(fileURLWithPath: "Path to pdf")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if let pdf = unlock(data: pdfData, password: "Hello World") { | |
print("You now have an unlocked CGPDFDocument") | |
} | |
func unlock(data: Data, password: String) -> CGPDFDocument? { | |
if let pdf = CGPDFDocument(CGDataProvider(data: data as CFData)!) { | |
guard pdf.isEncrypted == true else { return pdf } | |
guard pdf.unlockWithPassword("") == false else { return pdf } | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// PDF.swift | |
// | |
// Created by Ben Bahrenburg on 1/1/17. | |
// Copyright © 2017 bencoding.. All rights reserved. | |
// | |
import UIKit | |
open class PDFHelpers { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public func devicePasscodeEnabled() -> Bool { | |
return LAContext().canEvaluatePolicy(.deviceOwnerAuthentication, error: nil) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@available(iOS 8.0, *) | |
public func devicePasscodeEnabledUsingKeychain() -> Bool { | |
let query: [String:Any] = [ | |
kSecClass as String : kSecClassGenericPassword, | |
kSecAttrAccount as String : UUID().uuidString, | |
kSecAttrAccessible as String: kSecAttrAccessibleWhenPasscodeSetThisDeviceOnly, | |
kSecValueData as String: "HelloWorld".data(using: String.Encoding.utf8)!, | |
kSecReturnAttributes as String : kCFBooleanTrue | |
] | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// PasscodeUtils.swift | |
// | |
// Created by Ben Bahrenburg on 12/31/16. | |
// Copyright © 2016 bencoding.com. All rights reserved. | |
// | |
import Foundation | |
import LocalAuthentication |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<key>keychain-access-groups</key> | |
<array> | |
<string>$(AppIdentifierPrefix)com.bencoding.awesome-group</string> | |
</array> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let info = KeyChainAccessGroupHelper.getAccessGroupInfo() | |
//Use the default Keychain group | |
let keychain = Keychain(service: "com.example.github-token", accessGroup: info.rawValue) | |
//Use the prefix to connect to another keychain group | |
let keychain = Keychain(service: "com.example.github-token", accessGroup: String(format: "%@.com.bencoding.awesome-group", info.prefix)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// KeyStorage - Simplifying securely saving key information | |
// | |
// KeyChainAccessGroupHelper.swift | |
// Created by Ben Bahrenburg on 12/30/16. | |
// Copyright © 2017 bencoding.com. All rights reserved. | |
// | |
import Foundation | |
import Security |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Obfuscator.swift | |
// SwiftObfuscatorExample | |
// | |
// Created by Mathieu White on 2016-07-03. | |
// Copyright © 2016 Mathieu White. All rights reserved. | |
// | |
import Foundation |