Objective-C-RSA icon indicating copy to clipboard operation
Objective-C-RSA copied to clipboard

Add Decrypt function

Open Sean-Wang opened this issue 10 years ago • 9 comments

很好用的一个 RSA 第三方库,希望能够加上解密的功能。

Sean-Wang avatar Feb 04 '15 04:02 Sean-Wang

Swift implementation, also has decryption function: https://github.com/btnguyen2k/swift-rsautils

btnguyen2k avatar Jul 10 '15 17:07 btnguyen2k

@btnguyen2k Can you add Objective-C version descryption function to this project?

ideawu avatar Jul 12 '15 06:07 ideawu

@ideawu I have created a pull request for decryption function.

btnguyen2k avatar Jul 12 '15 15:07 btnguyen2k

how to decryption private key ?

coskungun avatar Sep 22 '15 10:09 coskungun

@coskungun, private key is a bit more complicated than I thought. I have add function to decrypt with private key in my Swift version: https://github.com/btnguyen2k/swift-rsautils

Still, encryption with private key has not worked yet. I will be investigating this a few more days and will update the ObjC code latter.

btnguyen2k avatar Sep 26 '15 09:09 btnguyen2k

Thanks to @btnguyen2k , we have more functions now:

+ (NSString *)decryptString:(NSString *)str publicKey:(NSString *)pubKey;
+ (NSData *)decryptData:(NSData *)data publicKey:(NSString *)pubKey;
+ (NSString *)decryptString:(NSString *)str privateKey:(NSString *)privKey;
+ (NSData *)decryptData:(NSData *)data privateKey:(NSString *)privKey;

ideawu avatar Sep 29 '15 06:09 ideawu

@btnguyen2k thank you very much. =)

coskungun avatar Sep 29 '15 08:09 coskungun

@ideawu : I want to do testing but when I try to decrypt using private_key it return nil.

specifically on the method : + (NSData *)stripPrivateKeyHeader:(NSData *)d_key the data is there (610 bytes long) but it returns nil after being stripped.

thidayatullah avatar Jan 24 '16 12:01 thidayatullah

ios9 真机调试下,RSA加密会随机失败,怎么解决,static public func encryptWithRSAPublicKey(data: NSData, pubkeyBase64: String, keychainTag: String) -> NSData? 方法随机返回 nil

stdawn avatar Mar 17 '16 15:03 stdawn