Skip to content

Instantly share code, notes, and snippets.

@songxing10000
Last active February 22, 2017 01:59
Show Gist options
  • Save songxing10000/587bd39abb1a66077770a14614567064 to your computer and use it in GitHub Desktop.
Save songxing10000/587bd39abb1a66077770a14614567064 to your computer and use it in GitHub Desktop.
private_key.p12 public_key.der
#import <Foundation/Foundation.h>
@interface RSAEncryptor : NSObject
/**
* 加密方法
*
* @param str 需要加密的字符串
* @param path '.der'格式的公钥文件路径
*/
+ (NSString *)encryptString:(NSString *)str publicKeyWithContentsOfFile:(NSString *)path;
/**
* 解密方法
*
* @param str 需要解密的字符串
* @param path '.p12'格式的私钥文件路径
* @param password 私钥文件密码
*/
+ (NSString *)decryptString:(NSString *)str privateKeyWithContentsOfFile:(NSString *)path password:(NSString *)password;
/**
* 加密方法
*
* @param str 需要加密的字符串
* @param pubKey 公钥字符串
*/
+ (NSString *)encryptString:(NSString *)str publicKey:(NSString *)pubKey;
/**
* 解密方法
*
* @param str 需要解密的字符串
* @param privKey 私钥字符串
*/
+ (NSString *)decryptString:(NSString *)str privateKey:(NSString *)privKey;
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment