8000 GitHub - xuvw/HKRSA: 用OC封装系统提供的接口实现RSA加密、解密、签名、验证
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
/ HKRSA Public

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

License

Notifications You must be signed in to change notification settings

xuvw/HKRSA

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HKRSA

用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 7120 :

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");
    }

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published
0