简体   繁体   中英

How encode with public key and decode with private?

I still have no simple method to do something like:

NSString *stringForEncrypt = @"Some string";
NSData *data = [string dataUsingEncoding:NSUTF8StringEncoding];
NSData *encryptedData = [data encryptWithPublicKey:public_key];
//....
NSData *decryptedData = [encryptedData decryptWithPrivateKey:private_key];
NSString *decryptedString = [NSString alloc] initWithData:decryptedData encoding:NSUTF8StringEncoding];

BOOL isItWorks = [stringForEncrypt isEqualToString:decryptedString];

Can I implement it using only Security.framework? Anybody?

我使用了NSData + AESCrypt ,这是我的解决方案

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM