日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

Ios: 如何保護iOS束文件屬性列表,圖像,SQLite,媒體文件

發布時間:2023/12/19 数据库 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Ios: 如何保護iOS束文件屬性列表,圖像,SQLite,媒體文件 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

Ios: 如何保護iOS束文件屬性列表,圖像,SQLite,媒體文件

我創建了Hello World示例項目,然後添加data.plist文件到資源文件夾。現在人們可以很容易得到束文件解壓縮。國際音標。有任何的方法來保護data.plist文件保存在iPhone應用程序包?

Encryption is a decent method of scrambling the data but i don't know how to implement encription concept.

你有什麼樣的代碼?

? ?NSString *filePath = [[NSBundle mainBundle] pathForResource:@"Data" ofType:@"plist"];
NSArray *arrData = [[NSArray alloc]initWithContentsOfFile:filePath];

NSData *datas = [NSKeyedArchiver archivedDataWithRootObject:arrData];
[datas writeToFile:filePath atomically:YES];

提取後的IPA文件

iosiphonebundleprotection

這個問題有 2 個解答。

1 個答案

使用nskeyedarchiver要從你的字典中創建一個NSData對象(nskeyedarchiver archiveddatawithrootobject:)。然後用AES加密NSData寫,你的文件。

閱讀只是相反的過程:首先,閱讀NSData,解密它通過從上述的連接方法,然後通過解密NSData到nskeyedunarchiver(nskeyedunarchiver unarchiveobjectwithdata:)你把你的字典回來。你可以使用NSDictionary plist文件或保持你的數據安全。

實例1:

實例2:

編輯2:

NSDictionary?*Your_NSDictionary?=?[NSDictionary?dictionaryWithObjectsAndKeys:@"Obj1",?@"Key1",@"Obj2",?@"Key2",?nil];//store?dictionaryNSMutableData?*yourData?=?[[NSMutableData?alloc]?init];NSKeyedArchiver?*archiver?=?[[NSKeyedArchiver?alloc]?initForWritingWithMutableData:data];[archiver?encodeObject:Your_NSDictionary?forKey:?@"key"];[archiver?finishEncoding];[yourData?writeToFile:@"FilePath"?atomically:YES];

NSString*?filePath?=?[[NSBundle?mainBundle]?pathForResource:@"Data"?ofType:@"plist"];NSDictionary*?data?=?[NSDictionary?dictionaryWithContentsOfFile:filePath];NSMutableDictionary?*?rootObject;rootObject?=?[NSMutableDictionary?dictionary];[rootObject?setValue:?data?forKey:@"accounts"];[NSKeyedArchiver?archiveRootObject:?rootObject?toFile:?path];

2 個答案

  • 在MAC加密文件…在部署:

    第一:要加密的目標不添加文件
    例如:Encryption-Test.plist

    然後添加一個shell腳本相Xcode項目使用openssl加密和複製文件。
    例如:
    openssl enc -e -aes-256-cbc -pass pass:asdasd-in $PROJECT_DIR/test/Encryption-Test.plist -out $TARGET_BUILD_DIR/$UNLOCALIZED_RESOURCES_FOLDER_PATH/Encryption-Test.enc

  • 從GitHub添加到你的項目rncryptor源文件。這使OpenSSL加密AES解密文件很容易。(感謝Rob!)https://github.com/rncryptor/rncryptor(蘋果的ccrypt API不好直接與工作)

  • 載入數據和解密:

  • 例如:

    @implementation?TestViewController-?(void)viewDidLoad{[super?viewDidLoad];NSString?*path?=?[[NSBundle?mainBundle]?pathForResource:@"Encryption-Test"?ofType:@"enc"];NSData?*passEncryptedData?=[[NSData?alloc]?initWithContentsOfFile:path];NSString?*pass?=?@"asdasd";NSData?*dataDecrypted?=?[RNOpenSSLDecryptor?decryptData:passEncryptedData?withSettings:kRNCryptorAES256Settings?password:pass?error:nil];id?plist?=?[NSPropertyListSerialization?propertyListFromData:dataDecrypted?mutabilityOption:NSPropertyListImmutable?format:nil?errorDescription:nil];assert(plist);self.text.text?=?[plist?description];}@end

    增加了全樣本:https://github.com/daij-djan/encryptbundlefiles

    如果本站有幫助到您,請不吝於給一個讚鼓勵!


    轉載于:https://blog.51cto.com/6951916/1752850

    總結

    以上是生活随笔為你收集整理的Ios: 如何保護iOS束文件屬性列表,圖像,SQLite,媒體文件的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。