Latest 0.0.1
Homepage https://github.com/xuvw/HKRSA
License MIT
Platforms ios 7.0, requires ARC
Frameworks Security
Authors

用OC封装系统提供的接口实现RSA加密、解密、签名、验证

Installation with CocoaPods

CocoaPods is a dependency manager for Objective-C, which automates and simplifies the process of using 3rd-party libraries like HKRSA in your projects. You can install it with the following command:

$ gem install cocoapods

Podfile

To integrate HKRSA into your Xcode project using CocoaPods, specify it in your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '7.0'

pod 'HKRSA'

Then, run the following command:

$ pod install

USAGE

加密、解密
    HKRSA *rsa = [HKRSA sharedInstance];
    [rsa loadPKFromFile:[[NSBundle mainBundle] pathForResource:@"public_key" ofType:@"der"]];
    [rsa loadSKFromFile:[[NSBundle mainBundle] pathForResource:@"private_key" ofType:@"p12"] password:@"123456"];

    NSString *rawString = @"CFNumberRef keySize = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &iKeySize);";
    NSString *encryString = [rsa encryptString:rawString];
    NSString *decryptString = [rsa decryptString:encryString];
    if (![rawString isEqualToString:decryptString]) {
        NSLog(@"加解密 failed");
    }
签名、验证
    HKRSA *rsa = [HKRSA sharedInstance];
    [rsa loadPKFromFile:[[NSBundle mainBundle] pathForResource:@"public_key" ofType:@"der"]];
    [rsa loadSKFromFile:[[NSBundle mainBundle] pathForResource:@"private_key" ofType:@"p12"] password:@"123456"];

    NSString *rawString = @"CFNumberRef keySize = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &iKeySize);";    
    NSString *signedString = [rsa signString:rawString withAbstractType:HKAbstractType_SHA384];
    BOOL result = [rsa verifyString:rawString withSignature:signedString withAbstractType:HKAbstractType_SHA384];
    if (!result) {
        NSLog(@"签名 failed");
    }

Latest podspec

{
    "name": "HKRSA",
    "version": "0.0.1",
    "summary": "u7528OCu5c01u88c5u4e86u7cfbu7edfu63d0u4f9bu7684RSAu76f8u5173u64cdu4f5c",
    "description": "u7528OCu5c01u88c5u4e86u7cfbu7edfu63d0u4f9bu7684RSAu76f8u5173u64cdu4f5cuff0cu5305u62ecuff1au52a0u5bc6u3001u89e3u5bc6u3001u7b7eu540du3001u9a8cu8bc1",
    "homepage": "https://github.com/xuvw/HKRSA",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "heke": "1052110478@qq.com"
    },
    "platforms": {
        "ios": "7.0"
    },
    "source": {
        "git": "https://github.com/xuvw/HKRSA.git",
        "tag": "0.0.1"
    },
    "source_files": "HKRSA/**/HKRSA.{h,m}",
    "frameworks": "Security",
    "requires_arc": true
}

Pin It on Pinterest

Share This