Open caocongcong opened 5 years ago
@caocongcong are we supposed to google translate your text?
dispatch_queue_t queue = dispatch_queue_create("test", DISPATCH_QUEUE_CONCURRENT); for (int i = 0; i< 100; i++) { dispatch_async(queue, ^{ NSString test = [[params md5String] uppercaseString]; NSString test1 = [self p_publicKey]; NSString *test2 = [RSA encryptString:test publicKey:test1]; if (test2.length == 0) { NSLog(@"出错啦"); NSLog(@"md5===%@", test); NSLog(@"pubkey===%@", test1); NSLog(@"encrypted===%@", test2); } else { NSLog(@"任务ccc===%@", test2); } }); }
会有出现test2为空的情况
我也遇到了 请问你解决了吗
我也遇见了,请问怎么解决.
RSA 在这个地方使用了公共的资源: https://github.com/ideawu/Objective-C-RSA/blob/master/RSA.m#L131 所以不是线程安全的. 目前的解决方案是在你的代码中避免多线程调用 encryptString().
RSA 在这个地方使用了公共的资源: https://github.com/ideawu/Objective-C-RSA/blob/master/RSA.m#L131 所以不是线程安全的. 目前的解决方案是在你的代码中避免多线程调用 encryptString().
本来RSA加解密比较耗时的,不放在多线程中,感觉不太好.
dispatch_queue_t queue = dispatch_queue_create("test", DISPATCH_QUEUE_CONCURRENT); for (int i = 0; i< 100; i++) { dispatch_async(queue, ^{ NSString test = [[params md5String] uppercaseString]; NSString test1 = [self p_publicKey]; NSString *test2 = [RSA encryptString:test publicKey:test1]; if (test2.length == 0) { NSLog(@"出错啦"); NSLog(@"md5===%@", test); NSLog(@"pubkey===%@", test1); NSLog(@"encrypted===%@", test2); } else { NSLog(@"任务ccc===%@", test2); } }); }
会有出现test2为空的情况