從bundle中擷取資料,明明把資料添加到項目中了,但就是不對。列印出來的都是空
//原始資料
NSString *originalString = @"這是一段将要使用'.der'檔案加密的字元串!";
//使用.der和.p12中的公鑰私鑰加密解密
NSString *public_key_path = [[NSBundle mainBundle] pathForResource:@"public_key.der" ofType:nil];
NSString *private_key_path = [[NSBundle mainBundle] pathForResource:@"private_key.p12" ofType:nil];
NSString *encryptStr = [RSAEncryptor encryptString:originalString publicKeyWithContentsOfFile:public_key_path];
NSLog(@"加密前:%@", originalString);
NSLog(@"加密後:%@", encryptStr);
NSLog(@"解密後:%@", [RSAEncryptor decryptString:encryptStr privateKeyWithContentsOfFile:private_key_path password:@"55555"]);
調試過程中,在轉碼代碼中打斷點,然後到了斷點處,在輸出台
po [NSString stringWithContentsOfFile:public_key_path encoding:kCFStringEncodingUTF8 error:nil]
發現列印
null
當時添加是直接拖拽過去,後來發現沒有真正加入到bundle中,需要在項目設定中,build phases-》copy bundle resources 下面添加自己的資料就可以了

引入之後運作列印
解決了,還有誰,哈哈