Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

并发时,SecItemCopyMatching方法会返回errSecItemNotFound #50

Open
caocongcong opened this issue Dec 7, 2018 · 5 comments
Open

Comments

@caocongcong
Copy link

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为空的情况

@okocsis
Copy link

okocsis commented Feb 4, 2019

@caocongcong are we supposed to google translate your text?

@SnailLife
Copy link

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为空的情况

我也遇到了 请问你解决了吗

@Tylor12
Copy link

Tylor12 commented Feb 25, 2020

我也遇见了,请问怎么解决.

@ideawu
Copy link
Owner

ideawu commented Feb 25, 2020

RSA 在这个地方使用了公共的资源: https://github.com/ideawu/Objective-C-RSA/blob/master/RSA.m#L131 所以不是线程安全的. 目前的解决方案是在你的代码中避免多线程调用 encryptString().

@Tylor12
Copy link

Tylor12 commented Feb 26, 2020

RSA 在这个地方使用了公共的资源: https://github.com/ideawu/Objective-C-RSA/blob/master/RSA.m#L131 所以不是线程安全的. 目前的解决方案是在你的代码中避免多线程调用 encryptString().

本来RSA加解密比较耗时的,不放在多线程中,感觉不太好.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants