Objective-C-RSA
Objective-C-RSA copied to clipboard
Add Decrypt function
很好用的一个 RSA 第三方库,希望能够加上解密的功能。
Swift implementation, also has decryption function: https://github.com/btnguyen2k/swift-rsautils
@btnguyen2k Can you add Objective-C version descryption function to this project?
@ideawu I have created a pull request for decryption function.
how to decryption private key ?
@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.
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;
@btnguyen2k thank you very much. =)
@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.
ios9 真机调试下,RSA加密会随机失败,怎么解决,static public func encryptWithRSAPublicKey(data: NSData, pubkeyBase64: String, keychainTag: String) -> NSData? 方法随机返回 nil