• OC RSA加密解密


    好久好久没有更新了。。。你们等的急不急。。这不,我就姗姗来迟了。。。本文重点讲解一下iOS系统下的RSA加密解密问题。

    一般为了安全,私钥是不会给前端暴露出来 的,只会通过私钥生成一个公开的公钥提供给外部对数据进行加密。将加密后的数据传给后端,后端使用私钥解密。比如支付宝支付,对接过这个支付的前端应该都知道。RSA的加密强度又有1024、2048之分,值越大,加密强度越高。

    具体的使用场景分为两种:

    1、自己有公钥文件,即后端生成的给你的一个.der文件,你将其放到你的项目中读取使用

    2、你调用接口给你直接返回公钥内容,你只是根据公钥直接加密数据

    针对以上两种使用场景,特封装以下两组方法,自己根据实际具体使用。

    先上代码:头文件RSATools.h

    1. //
    2. // RSAtools.h
    3. // SGBProject
    4. //
    5. // Created by carbonzhao on 2022/11/23.
    6. // Copyright © 2022 ZJKJ. All rights reserved.
    7. //
    8. #import
    9. #import
    10. NS_ASSUME_NONNULL_BEGIN
    11. @interface RSATools : NSObject
    12. #pragma mark -公钥、私钥文件
    13. /**
    14. * 加密方法,如果你使用的是公钥文件
    15. *
    16. * @param str 需要加密的字符串
    17. * @param path '.der'格式的公钥文件路径
    18. */
    19. + (NSString *)encryptPlainText:(NSString *)str publicKeyWithContentsOfFile:(NSString *)path;
    20. /**
    21. * 解密方法,如果你使用的是私钥文件,密码可为空,根据具体实际使用场景传值
    22. *
    23. * @param str 需要解密的字符串
    24. * @param path '.p12'格式的私钥文件路径
    25. * @param password 私钥文件密码
    26. */
    27. + (NSString *)decryptPlainText:(NSString *)str privateKeyWithContentsOfFile:(NSString *)path password:(NSString *)password;
    28. #pragma mark - 公钥私钥数据
    29. /**
    30. * 加密方法
    31. *
    32. * @param str 需要加密的字符串,此时不存在文件访问密码,故而不需要设置密码
    33. * @param pubKey 公钥字符串
    34. */
    35. + (NSString *)encryptPlainText:(NSString *)str publicKey:(NSString *)pubKey;
    36. /**
    37. * 解密方法
    38. *
    39. * @param str 需要解密的字符串
    40. * @param privKey 私钥字符串
    41. */
    42. + (NSString *)decryptPlainText:(NSString *)str privateKey:(NSString *)privKey;
    43. @end
    44. NS_ASSUME_NONNULL_END

    实现文件:RSATools.m

    1. //
    2. // RSATools.m
    3. // RSA
    4. //
    5. // Created by carbonzhao on 2022/11/23.
    6. //
    7. #import "RSATools.h"
    8. #import
    9. static NSString *base64_encode_data(NSData *data){
    10. data = [data base64EncodedDataWithOptions:0];
    11. NSString *ret = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
    12. return ret;
    13. }
    14. static NSData *base64_decode(NSString *str){
    15. NSData *data = [[NSData alloc] initWithBase64EncodedString:str options:NSDataBase64DecodingIgnoreUnknownCharacters];
    16. return data;
    17. }
    18. @implementation RSATools
    19. #pragma mark - 使用'.der'公钥文件加密
    20. //加密
    21. + (NSString *)encryptPlainText:(NSString *)str publicKeyWithContentsOfFile:(NSString *)path
    22. {
    23. if (!str || !path) return nil;
    24. return [self encryptPlainText:str publicKeyRef:[self getPublicKeyRefWithContentsOfFile:path]];
    25. }
    26. //获取公钥
    27. + (SecKeyRef)getPublicKeyRefWithContentsOfFile:(NSString *)filePath
    28. {
    29. NSData *certData = [NSData dataWithContentsOfFile:filePath];
    30. if (!certData) {
    31. return nil;
    32. }
    33. SecCertificateRef cert = SecCertificateCreateWithData(NULL, (CFDataRef)certData);
    34. SecKeyRef key = NULL;
    35. SecTrustRef trust = NULL;
    36. SecPolicyRef policy = NULL;
    37. if (cert != NULL) {
    38. policy = SecPolicyCreateBasicX509();
    39. if (policy) {
    40. if (SecTrustCreateWithCertificates((CFTypeRef)cert, policy, &trust) == noErr) {
    41. CFErrorRef errRef;
    42. if (SecTrustEvaluateWithError(trust, &errRef))
    43. {
    44. key = SecTrustCopyKey(trust);
    45. }
    46. }
    47. }
    48. }
    49. if (policy) CFRelease(policy);
    50. if (trust) CFRelease(trust);
    51. if (cert) CFRelease(cert);
    52. return key;
    53. }
    54. + (NSString *)encryptPlainText:(NSString *)str publicKeyRef:(SecKeyRef)publicKeyRef
    55. {
    56. if(![str dataUsingEncoding:NSUTF8StringEncoding] || !publicKeyRef)
    57. {
    58. return nil;
    59. }
    60. NSData *data = [self encryptData:[str dataUsingEncoding:NSUTF8StringEncoding] withKeyRef:publicKeyRef];
    61. NSString *ret = base64_encode_data(data);
    62. return ret;
    63. }
    64. #pragma mark - 使用'.12'私钥文件解密
    65. //解密
    66. + (NSString *)decryptPlainText:(NSString *)str privateKeyWithContentsOfFile:(NSString *)path password:(NSString *)password
    67. {
    68. if (!str || !path)
    69. {
    70. return nil;
    71. }
    72. if (!password)
    73. {
    74. password = @"";
    75. }
    76. return [self decryptPlainText:str privateKeyRef:[self getPrivateKeyRefWithContentsOfFile:path password:password]];
    77. }
    78. //获取私钥
    79. + (SecKeyRef)getPrivateKeyRefWithContentsOfFile:(NSString *)filePath password:(NSString*)password{
    80. NSData *p12Data = [NSData dataWithContentsOfFile:filePath];
    81. if (!p12Data)
    82. {
    83. return nil;
    84. }
    85. SecKeyRef privateKeyRef = NULL;
    86. NSMutableDictionary * options = [[NSMutableDictionary alloc] init];
    87. [options setObject: password forKey:(__bridge id)kSecImportExportPassphrase];
    88. CFArrayRef items = CFArrayCreate(NULL, 0, 0, NULL);
    89. OSStatus securityError = SecPKCS12Import((__bridge CFDataRef) p12Data, (__bridge CFDictionaryRef)options, &items);
    90. if (securityError == noErr && CFArrayGetCount(items) > 0)
    91. {
    92. CFDictionaryRef identityDict = CFArrayGetValueAtIndex(items, 0);
    93. SecIdentityRef identityApp = (SecIdentityRef)CFDictionaryGetValue(identityDict, kSecImportItemIdentity);
    94. securityError = SecIdentityCopyPrivateKey(identityApp, &privateKeyRef);
    95. if (securityError != noErr)
    96. {
    97. privateKeyRef = NULL;
    98. }
    99. }
    100. CFRelease(items);
    101. return privateKeyRef;
    102. }
    103. + (NSString *)decryptPlainText:(NSString *)str privateKeyRef:(SecKeyRef)privKeyRef{
    104. NSData *data = [[NSData alloc] initWithBase64EncodedString:str options:NSDataBase64DecodingIgnoreUnknownCharacters];
    105. if (!privKeyRef)
    106. {
    107. return nil;
    108. }
    109. data = [self decryptData:data withKeyRef:privKeyRef];
    110. NSString *ret = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
    111. return ret;
    112. }
    113. #pragma mark - 使用公钥字符串加密
    114. /* START: Encryption with RSA public key */
    115. //使用公钥字符串加密
    116. + (NSString *)encryptPlainText:(NSString *)str publicKey:(NSString *)pubKey
    117. {
    118. NSData *data = [self encryptData:[str dataUsingEncoding:NSUTF8StringEncoding] publicKey:pubKey];
    119. NSString *ret = base64_encode_data(data);
    120. return ret;
    121. }
    122. + (NSData *)encryptData:(NSData *)data publicKey:(NSString *)pubKey
    123. {
    124. if(!data || !pubKey){
    125. return nil;
    126. }
    127. SecKeyRef keyRef = [self addPublicKey:pubKey];
    128. if(!keyRef){
    129. return nil;
    130. }
    131. return [self encryptData:data withKeyRef:keyRef];
    132. }
    133. + (SecKeyRef)addPublicKey:(NSString *)key
    134. {
    135. NSRange spos = [key rangeOfString:@"-----BEGIN PUBLIC KEY-----"];
    136. NSRange epos = [key rangeOfString:@"-----END PUBLIC KEY-----"];
    137. if(spos.location != NSNotFound && epos.location != NSNotFound){
    138. NSUInteger s = spos.location + spos.length;
    139. NSUInteger e = epos.location;
    140. NSRange range = NSMakeRange(s, e-s);
    141. key = [key substringWithRange:range];
    142. }
    143. key = [key stringByReplacingOccurrencesOfString:@"\r" withString:@""];
    144. key = [key stringByReplacingOccurrencesOfString:@"\n" withString:@""];
    145. key = [key stringByReplacingOccurrencesOfString:@"\t" withString:@""];
    146. key = [key stringByReplacingOccurrencesOfString:@" " withString:@""];
    147. // This will be base64 encoded, decode it.
    148. NSData *data = base64_decode(key);
    149. data = [self stripPublicKeyHeader:data];
    150. if(!data){
    151. return nil;
    152. }
    153. //a tag to read/write keychain storage
    154. NSString *tag = @"RSAUtil_PubKey";
    155. NSData *d_tag = [NSData dataWithBytes:[tag UTF8String] length:[tag length]];
    156. // Delete any old lingering key with the same tag
    157. NSMutableDictionary *publicKey = [[NSMutableDictionary alloc] init];
    158. [publicKey setObject:(__bridge id) kSecClassKey forKey:(__bridge id)kSecClass];
    159. [publicKey setObject:(__bridge id) kSecAttrKeyTypeRSA forKey:(__bridge id)kSecAttrKeyType];
    160. [publicKey setObject:d_tag forKey:(__bridge id)kSecAttrApplicationTag];
    161. SecItemDelete((__bridge CFDictionaryRef)publicKey);
    162. // Add persistent version of the key to system keychain
    163. [publicKey setObject:data forKey:(__bridge id)kSecValueData];
    164. [publicKey setObject:(__bridge id) kSecAttrKeyClassPublic forKey:(__bridge id)
    165. kSecAttrKeyClass];
    166. [publicKey setObject:[NSNumber numberWithBool:YES] forKey:(__bridge id)
    167. kSecReturnPersistentRef];
    168. CFTypeRef persistKey = nil;
    169. OSStatus status = SecItemAdd((__bridge CFDictionaryRef)publicKey, &persistKey);
    170. if (persistKey != nil){
    171. CFRelease(persistKey);
    172. }
    173. if ((status != noErr) && (status != errSecDuplicateItem)) {
    174. return nil;
    175. }
    176. [publicKey removeObjectForKey:(__bridge id)kSecValueData];
    177. [publicKey removeObjectForKey:(__bridge id)kSecReturnPersistentRef];
    178. [publicKey setObject:[NSNumber numberWithBool:YES] forKey:(__bridge id)kSecReturnRef];
    179. [publicKey setObject:(__bridge id) kSecAttrKeyTypeRSA forKey:(__bridge id)kSecAttrKeyType];
    180. // Now fetch the SecKeyRef version of the key
    181. SecKeyRef keyRef = nil;
    182. status = SecItemCopyMatching((__bridge CFDictionaryRef)publicKey, (CFTypeRef *)&keyRef);
    183. if(status != noErr){
    184. return nil;
    185. }
    186. return keyRef;
    187. }
    188. + (NSData *)stripPublicKeyHeader:(NSData *)d_key{
    189. // Skip ASN.1 public key header
    190. if (d_key == nil) return(nil);
    191. unsigned long len = [d_key length];
    192. if (!len) return(nil);
    193. unsigned char *c_key = (unsigned char *)[d_key bytes];
    194. unsigned int idx = 0;
    195. if (c_key[idx++] != 0x30) return(nil);
    196. if (c_key[idx] > 0x80) idx += c_key[idx] - 0x80 + 1;
    197. else idx++;
    198. // PKCS #1 rsaEncryption szOID_RSA_RSA
    199. static unsigned char seqiod[] =
    200. { 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01,
    201. 0x01, 0x05, 0x00 };
    202. if (memcmp(&c_key[idx], seqiod, 15)) return(nil);
    203. idx += 15;
    204. if (c_key[idx++] != 0x03) return(nil);
    205. if (c_key[idx] > 0x80) idx += c_key[idx] - 0x80 + 1;
    206. else idx++;
    207. if (c_key[idx++] != '\0') return(nil);
    208. // Now make a new NSData from this buffer
    209. return ([NSData dataWithBytes:&c_key[idx] length:len - idx]);
    210. }
    211. + (NSData *)encryptData:(NSData *)data withKeyRef:(SecKeyRef) keyRef{
    212. const uint8_t *srcbuf = (const uint8_t *)[data bytes];
    213. size_t srclen = (size_t)data.length;
    214. size_t block_size = SecKeyGetBlockSize(keyRef) * sizeof(uint8_t);
    215. void *outbuf = malloc(block_size);
    216. size_t src_block_size = block_size - 11;
    217. NSMutableData *ret = [[NSMutableData alloc] init];
    218. for(int idx=0; idx
    219. //NSLog(@"%d/%d block_size: %d", idx, (int)srclen, (int)block_size);
    220. size_t data_len = srclen - idx;
    221. if(data_len > src_block_size){
    222. data_len = src_block_size;
    223. }
    224. size_t outlen = block_size;
    225. OSStatus status = noErr;
    226. status = SecKeyEncrypt(keyRef,
    227. kSecPaddingPKCS1,
    228. srcbuf + idx,
    229. data_len,
    230. outbuf,
    231. &outlen
    232. );
    233. if (status != 0) {
    234. NSLog(@"SecKeyEncrypt fail. Error Code: %d", status);
    235. ret = nil;
    236. break;
    237. }else{
    238. [ret appendBytes:outbuf length:outlen];
    239. }
    240. }
    241. free(outbuf);
    242. CFRelease(keyRef);
    243. return ret;
    244. }
    245. /* END: Encryption with RSA public key */
    246. #pragma mark - 使用私钥字符串解密
    247. /* START: Decryption with RSA private key */
    248. //使用私钥字符串解密
    249. + (NSString *)decryptPlainText:(NSString *)str privateKey:(NSString *)privKey
    250. {
    251. if (!str) return nil;
    252. NSData *data = [[NSData alloc] initWithBase64EncodedString:str options:NSDataBase64DecodingIgnoreUnknownCharacters];
    253. data = [self decryptData:data privateKey:privKey];
    254. NSString *ret = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
    255. return ret;
    256. }
    257. + (NSData *)decryptData:(NSData *)data privateKey:(NSString *)privKey
    258. {
    259. if(!data || !privKey){
    260. return nil;
    261. }
    262. SecKeyRef keyRef = [self addPrivateKey:privKey];
    263. if(!keyRef){
    264. return nil;
    265. }
    266. return [self decryptData:data withKeyRef:keyRef];
    267. }
    268. + (SecKeyRef)addPrivateKey:(NSString *)key
    269. {
    270. NSRange spos = [key rangeOfString:@"-----BEGIN RSA PRIVATE KEY-----"];
    271. NSRange epos = [key rangeOfString:@"-----END RSA PRIVATE KEY-----"];
    272. if(spos.location != NSNotFound && epos.location != NSNotFound){
    273. NSUInteger s = spos.location + spos.length;
    274. NSUInteger e = epos.location;
    275. NSRange range = NSMakeRange(s, e-s);
    276. key = [key substringWithRange:range];
    277. }
    278. key = [key stringByReplacingOccurrencesOfString:@"\r" withString:@""];
    279. key = [key stringByReplacingOccurrencesOfString:@"\n" withString:@""];
    280. key = [key stringByReplacingOccurrencesOfString:@"\t" withString:@""];
    281. key = [key stringByReplacingOccurrencesOfString:@" " withString:@""];
    282. // This will be base64 encoded, decode it.
    283. NSData *data = base64_decode(key);
    284. data = [self stripPrivateKeyHeader:data];
    285. if(!data){
    286. return nil;
    287. }
    288. //a tag to read/write keychain storage
    289. NSString *tag = @"RSAUtil_PrivKey";
    290. NSData *d_tag = [NSData dataWithBytes:[tag UTF8String] length:[tag length]];
    291. // Delete any old lingering key with the same tag
    292. NSMutableDictionary *privateKey = [[NSMutableDictionary alloc] init];
    293. [privateKey setObject:(__bridge id) kSecClassKey forKey:(__bridge id)kSecClass];
    294. [privateKey setObject:(__bridge id) kSecAttrKeyTypeRSA forKey:(__bridge id)kSecAttrKeyType];
    295. [privateKey setObject:d_tag forKey:(__bridge id)kSecAttrApplicationTag];
    296. SecItemDelete((__bridge CFDictionaryRef)privateKey);
    297. // Add persistent version of the key to system keychain
    298. [privateKey setObject:data forKey:(__bridge id)kSecValueData];
    299. [privateKey setObject:(__bridge id) kSecAttrKeyClassPrivate forKey:(__bridge id)
    300. kSecAttrKeyClass];
    301. [privateKey setObject:[NSNumber numberWithBool:YES] forKey:(__bridge id)
    302. kSecReturnPersistentRef];
    303. CFTypeRef persistKey = nil;
    304. OSStatus status = SecItemAdd((__bridge CFDictionaryRef)privateKey, &persistKey);
    305. if (persistKey != nil){
    306. CFRelease(persistKey);
    307. }
    308. if ((status != noErr) && (status != errSecDuplicateItem)) {
    309. return nil;
    310. }
    311. [privateKey removeObjectForKey:(__bridge id)kSecValueData];
    312. [privateKey removeObjectForKey:(__bridge id)kSecReturnPersistentRef];
    313. [privateKey setObject:[NSNumber numberWithBool:YES] forKey:(__bridge id)kSecReturnRef];
    314. [privateKey setObject:(__bridge id) kSecAttrKeyTypeRSA forKey:(__bridge id)kSecAttrKeyType];
    315. // Now fetch the SecKeyRef version of the key
    316. SecKeyRef keyRef = nil;
    317. status = SecItemCopyMatching((__bridge CFDictionaryRef)privateKey, (CFTypeRef *)&keyRef);
    318. if(status != noErr){
    319. return nil;
    320. }
    321. return keyRef;
    322. }
    323. + (NSData *)stripPrivateKeyHeader:(NSData *)d_key
    324. {
    325. // Skip ASN.1 private key header
    326. if (d_key == nil) return(nil);
    327. unsigned long len = [d_key length];
    328. if (!len) return(nil);
    329. unsigned char *c_key = (unsigned char *)[d_key bytes];
    330. unsigned int idx = 22; //magic byte at offset 22
    331. if (0x04 != c_key[idx++]) return nil;
    332. //calculate length of the key
    333. unsigned int c_len = c_key[idx++];
    334. int det = c_len & 0x80;
    335. if (!det) {
    336. c_len = c_len & 0x7f;
    337. } else {
    338. int byteCount = c_len & 0x7f;
    339. if (byteCount + idx > len) {
    340. //rsa length field longer than buffer
    341. return nil;
    342. }
    343. unsigned int accum = 0;
    344. unsigned char *ptr = &c_key[idx];
    345. idx += byteCount;
    346. while (byteCount) {
    347. accum = (accum << 8) + *ptr;
    348. ptr++;
    349. byteCount--;
    350. }
    351. c_len = accum;
    352. }
    353. // Now make a new NSData from this buffer
    354. return [d_key subdataWithRange:NSMakeRange(idx, c_len)];
    355. }
    356. + (NSData *)decryptData:(NSData *)data withKeyRef:(SecKeyRef) keyRef{
    357. const uint8_t *srcbuf = (const uint8_t *)[data bytes];
    358. size_t srclen = (size_t)data.length;
    359. size_t block_size = SecKeyGetBlockSize(keyRef) * sizeof(uint8_t);
    360. UInt8 *outbuf = malloc(block_size);
    361. size_t src_block_size = block_size;
    362. NSMutableData *ret = [[NSMutableData alloc] init];
    363. for(int idx=0; idx
    364. //NSLog(@"%d/%d block_size: %d", idx, (int)srclen, (int)block_size);
    365. size_t data_len = srclen - idx;
    366. if(data_len > src_block_size){
    367. data_len = src_block_size;
    368. }
    369. size_t outlen = block_size;
    370. OSStatus status = noErr;
    371. status = SecKeyDecrypt(keyRef,
    372. kSecPaddingNone,
    373. srcbuf + idx,
    374. data_len,
    375. outbuf,
    376. &outlen
    377. );
    378. if (status != 0) {
    379. NSLog(@"SecKeyEncrypt fail. Error Code: %d", status);
    380. ret = nil;
    381. break;
    382. }else{
    383. //the actual decrypted data is in the middle, locate it!
    384. int idxFirstZero = -1;
    385. int idxNextZero = (int)outlen;
    386. for ( int i = 0; i < outlen; i++ ) {
    387. if ( outbuf[i] == 0 ) {
    388. if ( idxFirstZero < 0 ) {
    389. idxFirstZero = i;
    390. } else {
    391. idxNextZero = i;
    392. break;
    393. }
    394. }
    395. }
    396. [ret appendBytes:&outbuf[idxFirstZero+1] length:idxNextZero-idxFirstZero-1];
    397. }
    398. }
    399. free(outbuf);
    400. CFRelease(keyRef);
    401. return ret;
    402. }
    403. @end

    测试方法:首先先登录下面的网站:http://web.chacuo.net/netrsakeypair, ,这是一个在线生成RSA秘钥的网站, 生成公钥和秘钥后, 复制出来用于测试.注意使用时要删除掉前面:

    -----BEGIN PUBLIC KEY-----

    -----END PUBLIC KEY-----

    -----BEGIN PRIVATE KEY-----

    -----END PRIVATE KEY-----

    这两组标签,同时删除回车换行符!!!!。

    1. NSString *encryptStr = [RSATools encryptPlainText:originalString publicKey:@"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA+MWh4qVoaGpC17Fh9Ybbci9dQpJ6SUAqKCcT4SVcRFyvLQqj68RLDHZsA9TcjSYUpm2YS7bi0vJXPBHRgZpthhH6wcEgF+7OAdQAfKsaQ20wHjUMU8k5qyK8KGj6oVbWJxGoFOtKSXNdRLSn9immUX+EDZvcfzkd8NSJV/SDTunHxtIZ/w/KHnMeeSioNpNq2lKnQsXeJzA9CDoc1tUMbcVmKO0Rplygq4bOOQTFBZnzzGIxNjJFPo24IUEQ3mwl/36NvioT9vva4XJy+DY1Xz+7QY+rPb9FmW5rbg+TuYc7J+82BpJ2BihLt/b2507UFsNgJ6SMmn3cmX0INdr0mwIDAQAB"];
    2. NSLog(@"加密前:%@", originalString);
    3. NSLog(@"加密后:%@", encryptStr);
    4. NSString *deText = [RSATools decryptPlainText:encryptStr privateKey:@"MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQD4xaHipWhoakLXsWH1httyL11CknpJQCooJxPhJVxEXK8tCqPrxEsMdmwD1NyNJhSmbZhLtuLS8lc8EdGBmm2GEfrBwSAX7s4B1AB8qxpDbTAeNQxTyTmrIrwoaPqhVtYnEagU60pJc11EtKf2KaZRf4QNm9x/OR3w1IlX9INO6cfG0hn/D8oecx55KKg2k2raUqdCxd4nMD0IOhzW1QxtxWYo7RGmXKCrhs45BMUFmfPMYjE2MkU+jbghQRDebCX/fo2+KhP2+9rhcnL4NjVfP7tBj6s9v0WZbmtuD5O5hzsn7zYGknYGKEu39vbnTtQWw2AnpIyafdyZfQg12vSbAgMBAAECggEAUlBqiWj7zBjk9yO9axVtRTIA5Mc86UHu8QxFGqlXB1O3ruqnZJq1znDcusPTGm0wRgVbcCoakXwYe0rWDNFBTixi0XuKmACvb5Fre9TNwuO9GTGqW4ropwS+R4y86WenQpQoDovwL6+Ze+Ne9CfB3ZOY6TvaUMpgatCYhV7ll9VCAMn3+KB6cxZPqByx3W0MdGt7LlKENGs7ARrSxfd33WHSQMfVGhTmt1or6OC+kVZ1rXNkuGVuQzBqA4iVKbDAhly9sTmyUPUaDloVrG2FH7+Ab2d9G/GLt22xU7Om8HlWTmGJGIy4F9/a53Kzx5NYwHpKLdDAzyAuziSS8nyF6QKBgQD83bLm7/FwbPd3n9/JODbNdFrDoJRZVTKKDgqnzsD1YIaeN2QU4ifBu2fnhOUwSn8f7VJniafps/wSnfXhcrLdQw0jJEFccvzmM+WuJu0ZLHsHCZr/Y/ex2l7GiawFNc3iDFCspWnnpJxLSyzWCmfPMDXVcSvnA9kVKv9a6pJJRwKBgQD72vGlL8RYWkR//gHQjd6C0Z9aexXybyOpCH7cl0lwzFG7paAajW3wxd7alDGgTJgbNl+gKy/ciBHr672kYquHPowShYQ8GCMLcfdlFN6DQZmx283BMJOySYWSMxV65HpPUxU48se4ger6itO/QKsXUa+18WGJStdgtYH5GIbkDQKBgQCPNwliXreCE1U9fWED2EDBsIrPjZ0301cidb13OVR0JU1ZQsn+QfB+eyPoLo6YATlq3cD0PzTI2lWEPc7K92lyg81m/9u8/qtZvj7xmb5jqZusarZMu1PIeYOAMu0orkaDJrJydeU7ezHCOzuTpqUQ5Z832jchSj6jDI0/8ucTdQKBgHloCaR/aj7NBMhOQcGvIdweAJs1SlcbjC0nkz/zDcv6MkwqgwtJsf2m5M6pMWL8iTZU97PWHbRJQ5pegYSEq/r+A7fJ9PyjBgG2ZnOro7fSH6zFMGI4cHo5RtI7Hden2+3xNwHExtICjqtH0NsY6WDMV891FHeCRGCyHn1dfWjhAoGAEab7DtSSnIkC5xly3+DuAeOLQQ3LqqFfgnfQBH4Euj2ba6KGcOruJcYqnTG7G8Zz84+5wz0zjzvVwCvTWftrdlM9S5g479Ugs/L2E4arOZov4cu5PJ8J24V5BXskD8WSXUF9+0lWfuzJs/8TDiGOt+V290J0cgSs/AVTkZGuGfo="];
    5. NSLog(@"解密后:%@", deText);

  • 相关阅读:
    第五届美团网络安全高校挑战赛团体初赛writeup
    No169.精选前端面试题,享受每天的挑战和学习
    torch.nn.init.kaiming_normal_
    【Elasticsearch】数据简单操作(二)
    简单对比一下 C 与 Go 两种语言
    Epoller
    C++入门教程(十一、宏)
    面试真题汇总430家
    【重新安装Anaconda心得】
    【数据结构】链表详解
  • 原文地址:https://blog.csdn.net/yunhuaikong/article/details/127996085