ideawu / Objective-C-RSA

Doing RSA encryption and decryption with Objective-C on iOS
http://www.ideawu.com/blog/post/132.html
Other
1.15k stars 280 forks source link

Add Decrypt function #1

Open Sean-Wang opened 9 years ago

Sean-Wang commented 9 years ago

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

btnguyen2k commented 9 years ago

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

ideawu commented 9 years ago

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

btnguyen2k commented 9 years ago

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

coskungun commented 8 years ago

how to decryption private key ?

btnguyen2k commented 8 years ago

@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.

ideawu commented 8 years ago

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;
coskungun commented 8 years ago

@btnguyen2k thank you very much. =)

thidayatullah commented 8 years ago

@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.

stdawn commented 8 years ago

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