Package 加密 Key: "zaq1xsw2cde3vfr4"
Password 加密 Key Prefix: "1qaz2wsx"
Exception Domains 設定 Key 值
NSExceptionAllowsInsecureHTTPLoads
NSIncludesSubdomains
Data+RNCrypt.swift (0811 1450)
//
// Data+RNCryptor.swift
// HelloMySecureApp
//
// Created by Kent Liu on 2018/8/11.
// Copyright © 2018年 SoftArts Inc. All rights reserved.
//
import Foundation
import RNCryptor
extension Data {
func decrypt( key: String ) -> Data ? {
// Convert base64 encoded data to original data
guard let encryptedData = Data ( base64Encoded: self ) else {
print ( " Fail to convert base64 to data. " )
return nil
}
guard let decryptedData = try ? RNCryptor . decrypt ( data: encryptedData, withPassword: key) else {
assertionFailure ( " Fail to decrypt. " )
return nil
}
return decryptedData
}
func decryptToString( key: String ) -> String ? {
guard let data = decrypt ( key: key) else {
return nil
}
guard let string = String ( data: data, encoding: . utf8) else {
print ( " Fail to convert data to string. " )
return nil
}
return string
}
}
僅支援有登記UDID的裝置
Bundle ID: com.kent.dataprotectiondemo
P12密碼: 1qaz2wsx
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=",
"BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB="
import Foundation
import UIKit
autoreleasepool {
UIApplicationMain (
CommandLine . argc,
UnsafeMutableRawPointer ( CommandLine . unsafeArgv)
. bindMemory (
to: UnsafeMutablePointer< Int8> . self ,
capacity: Int ( CommandLine . argc)
) ,
nil ,
NSStringFromClass ( AppDelegate . self) //Or your class name
)
}