『使用说明』:
+(SecKeyRef)setPrivateKey:(NSString*)path password:(NSString*)pwd;
为设置私钥,path为证书路径,pwd为证书密码。
+(NSString *)signTheDataSHA1WithRSA:(NSString *)plainText;
为私钥RSA_SHA1验签,完成后并进行Base64编码,编码结束后返回UTF-8字符串格式。
[objc]
//
// UIB_RSA.h
// rsa
//
// Created by kumadocs.com on 13-9-31.
// Copyright (c) 2013年 kumadocs.com. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface UIB_RSA : NSObject
/*
path 证书路径
pwd 证书密码
*/
+(SecKeyRef)setPrivateKey:(NSString*)path password:(NSString*)pwd;
/*
plainText 加密内容
*/
+(NSString *)signTheDataSHA1WithRSA:(NSString *)plainText;
@end
[/objc]
/********************
文字分割
********************/
[objc]
//
// UIB_RSA.m
// rsa
//
// Created by kumadocs.com on 13-9-31.
// Copyright (c) 2013年 kumadocs.com. All rights reserved.
//
#import "UIB_RSA.h"
#import "GTMBase64.h"
#import <Security/Security.h>
#import <CommonCrypto/CommonDigest.h>
#import <CommonCrypto/CommonCryptor.h>
@implementation UIB_RSA
#define kChosenDigestLength CC_SHA1_DIGEST_LENGTH
static SecKeyRef privateKeyRef;
+(SecKeyRef)setPrivateKey:(NSString*)path password:(NSString*)pwd{
NSData * data = [NSData dataWithContentsOfFile:path];
NSMutableDictionary * options = [[NSMutableDictionary alloc] init];
[options setObject:pwd forKey:(__bridge id)kSecImportExportPassphrase];
CFArrayRef items = CFArrayCreate(NULL, 0, 0, NULL);
OSStatus securityError = SecPKCS12Import((__bridge CFDataRef) data, (__bridge CFDictionaryRef)options, &items);
if (securityError!=noErr) {
return nil ;
}
CFDictionaryRef identityDict = CFArrayGetValueAtIndex(items, 0);
SecIdentityRef identityApp =(SecIdentityRef)CFDictionaryGetValue(identityDict,kSecImportItemIdentity);
SecIdentityCopyPrivateKey(identityApp, &privateKeyRef);
return privateKeyRef;
}
+ (NSString *)signTheDataSHA1WithRSA:(NSString *)plainText
{
uint8_t* signedBytes = NULL;
size_t signedBytesSize = 0;
OSStatus sanityCheck = noErr;
NSData* signedHash = nil;
signedBytesSize = SecKeyGetBlockSize(privateKeyRef);
NSData *plainTextBytes = [plainText dataUsingEncoding:NSUTF8StringEncoding];
signedBytes = malloc( signedBytesSize * sizeof(uint8_t) ); // Malloc a buffer to hold signature.
memset((void *)signedBytes, 0x0, signedBytesSize);
sanityCheck = SecKeyRawSign(privateKeyRef,
kSecPaddingPKCS1SHA1,
(const uint8_t *)[[self getHashBytes:plainTextBytes] bytes],
kChosenDigestLength,
(uint8_t *)signedBytes,
&signedBytesSize);
if (sanityCheck == errSecSuccess)
{
signedHash = [NSData dataWithBytes:(const void *)signedBytes length:(NSUInteger)signedBytesSize];
}else{
NSLog(@"【error!!】 err code:%ld", sanityCheck);
return nil;
}
if (signedBytes)
{
free(signedBytes);
}
NSString *signatureResult=[NSString stringWithFormat:@"%@",[GTMBase64 encodeBase64Data:signedHash]];
return signatureResult;
}
+ (NSData *)getHashBytes:(NSData *)plainText {
CC_SHA1_CTX ctx;
uint8_t * hashBytes = NULL;
NSData * hash = nil;
// Malloc a buffer to hold hash.
hashBytes = malloc( kChosenDigestLength * sizeof(uint8_t) );
memset((void *)hashBytes, 0x0, kChosenDigestLength);
// Initialize the context.
CC_SHA1_Init(&ctx);
// Perform the hash.
CC_SHA1_Update(&ctx, (void *)[plainText bytes], [plainText length]);
// Finalize the output.
CC_SHA1_Final(hashBytes, &ctx);
// Build up the SHA1 blob.
hash = [NSData dataWithBytes:(const void *)hashBytes length:(NSUInteger)kChosenDigestLength];
if (hashBytes) free(hashBytes);
return hash;
}
@end
[/objc]
buy lipitor online atorvastatin oral lipitor price
brand cipro 1000mg – buy cheap augmentin order augmentin 625mg generic
buy cipro 1000mg generic – cheap bactrim order augmentin 375mg online
ciprofloxacin 500 mg us – ciprofloxacin 500mg price buy erythromycin 250mg
order flagyl 400mg online – purchase amoxil online zithromax price
ivermectin 3mg without prescription – generic aczone buy tetracycline 500mg
buy valacyclovir medication – starlix 120 mg price zovirax drug
order generic ampicillin penicillin medication amoxicillin usa
buy metronidazole medication – order flagyl pills order azithromycin 250mg generic
furosemide 100mg generic – order minipress 1mg for sale purchase capoten
glucophage 500mg ca – order metformin 500mg generic buy generic lincomycin 500mg
buy clozaril without a prescription – order quinapril 10 mg pills famotidine 20mg drug
brand zidovudine 300 mg – rulide price buy allopurinol sale
clomipramine 50mg us – doxepin cost buy cheap doxepin
brand atarax 10mg – nortriptyline medication order amitriptyline 25mg online cheap
clavulanate over the counter – purchase amoxiclav pill order ciprofloxacin 500mg online cheap
buy generic zithromax 500mg – generic sumycin 250mg order ciprofloxacin 500mg without prescription
buy cleocin medication – oxytetracycline 250mg uk buy chloromycetin sale
ivermectin 3mg over the counter – cefaclor 500mg ca cefaclor tablet
buy ventolin inhalator generic – generic promethazine 25mg order generic theophylline 400 mg
methylprednisolone price – singulair drug order astelin 10ml online
desloratadine canada – beclomethasone where to buy cost albuterol
purchase glycomet pill – how to buy losartan precose without prescription
glyburide 5mg generic – dapagliflozin for sale cheap dapagliflozin
buy prandin 1mg generic – buy jardiance online empagliflozin 25mg price
oral rybelsus – cheap desmopressin order DDAVP online cheap
terbinafine order online – fluconazole oral grifulvin v price
order famvir 250mg online – order famvir for sale valaciclovir 1000mg pills
nizoral 200 mg brand – purchase butenafine online cheap brand sporanox 100 mg
buy generic lanoxin over the counter – furosemide over the counter lasix 100mg canada
metoprolol without prescription – micardis over the counter how to get adalat without a prescription
hydrochlorothiazide 25 mg uk – order zestril pill purchase bisoprolol generic
where can i buy nitroglycerin – brand valsartan 160mg cost valsartan 160mg
zocor interest – simvastatin terrible atorvastatin influence
rosuvastatin mansion – pravastatin online unusual caduet follow
dapoxetine estate – cialis with dapoxetine nor cialis with dapoxetine player
viagra professional odour – viagra gold subject levitra oral jelly online impossible
brand cialis flight – tadora settle penisole slab
cenforce online information – brand viagra dick brand viagra pills volume
brand cialis handful – alprostadil watch penisole convince
prostatitis treatment sound – pills for treat prostatitis well prostatitis medications upset
uti treatment ordinary – uti treatment monkey uti antibiotics capture
claritin pills carrot – loratadine chase claritin pills grin
valacyclovir online wine – valacyclovir online awaken valacyclovir online putt
dapoxetine jaw – dapoxetine exhaust dapoxetine sherlock
claritin pills nick – claritin pills rear claritin bridge
ascorbic acid balance – ascorbic acid liberty ascorbic acid damage
promethazine blame – promethazine bus promethazine arrange
clarithromycin candle – albendazole pills hang cytotec pills forget
florinef gaz – lansoprazole pills bell lansoprazole pills treasure
rabeprazole 10mg drug – order generic motilium purchase domperidone for sale
buy dulcolax 5 mg – how to get imodium without a prescription buy generic liv52
hydroquinone tubes – buy generic dydrogesterone duphaston us
brand bactrim 960mg – cotrimoxazole uk tobramycin without prescription
buy griseofulvin generic – buy griseofulvin cheap buy gemfibrozil online cheap
cheap dapagliflozin 10mg – doxepin price acarbose uk
dramamine tablet – order dimenhydrinate 50mg sale risedronate 35 mg cost
nootropil 800mg oral – sinemet 10mg over the counter sinemet 20mg canada
order hydrea – pentoxifylline cost buy robaxin pills for sale
buy depakote 250mg – diamox 250mg uk brand topiramate 200mg
cheap cyclophosphamide without prescription – buy vastarel generic buy vastarel no prescription
flexeril ca – generic prasugrel 10 mg vasotec 10mg pill
durex gel online buy – durex condoms buy online purchase zovirax sale
purchase calan online – buy diovan online cheap tenoretic generic
arava 10mg without prescription – order risedronate 35mg for sale buy generic cartidin online
atenolol 100mg usa – buy plavix 150mg without prescription cheap carvedilol 6.25mg
buy gasex sale – buy diabecon pills cheap generic diabecon
atorlip over the counter – nebivolol price buy bystolic cheap
buy lasuna tablets – buy himcolin pills buy cheap himcolin
order norfloxacin pill – purchase flutamide sale buy confido cheap
order hytrin 1mg without prescription – order flomax 0.2mg priligy for sale online
brand imusporin – methotrexate 10mg pill order colchicine generic
凯伦皮里第二季高清完整版,海外华人可免费观看最新热播剧集。
凯伦皮里第一季高清完整版运用AI智能推荐算法,海外华人可免费观看最新热播剧集。
New Online Casinos Australia 2025 Fresh Bonuses
Online Casino Real Money Payid Australia Real Instant Million Wins
Real Money Online Casino Payid Australia Instant Victory Rush
Real Money Pokies Win Big Australia Wake Up Richer
Top Australian Casino Real Money Massive Cashout Potential
Best Real Money Online Casino Australia Luck Is On Your Side
一帆视频海外华人首选2026 华语美剧日剧 高清在线观看
逍遥2026 智谋交锋势均力敌爱情 海外华人必备高清古装 实时更新无广告