| 注册
请输入搜索内容

热门搜索

Java Linux MySQL PHP JavaScript Hibernate jQuery Nginx
jopen
9年前发布

iOS安全加密:AES-RSA-For-iOS

iOS,安全加密。采用RSA签名和AES随机秘钥加密,AES的随机秘钥采用RSA加密。密码0123456789abcdef
加密字段1加密结果:2yPBJGtAg/AfuvT8idAmzw==

   NSMutableDictionary *resultDic = [[NSMutableDictionary alloc]initWithCapacity:1];      //step1 对报文数据源排序a->z      NSMutableArray *sortedArray = [self sortDictionary:EncryptDic];      //step2 取出排序过后数组的value,拼成string      NSMutableArray *arrayOfValues = [NSMutableArray arrayWithArray:sortedArray];      NSString *paramValue = [arrayOfValues componentsJoinedByString:@""];      //step3 根据RAS私有密钥签名业务请求参数值字符串(paramValue),生成基于SHA1的RSA数字签名      CRSA *t = [CRSA shareInstance];      NSString *sign = [t encryptByRsa:paramValue withKeyType:KeyTypePrivate];      //step4 将签名放入原报文      NSMutableDictionary *dicWithSign = [NSMutableDictionary dictionaryWithDictionary:EncryptDic];      [dicWithSign setObject:sign forKey:@"sign"];      //step5 随机生成16位数字和字母组成的      NSString *merchantAesKey = [LcAESRSA set32bitString:16];      NSLog(@"\rAES key :%@",merchantAesKey);      //step6 用16位随机码加密含有签名的报文      SBJsonWriter * parser = [[SBJsonWriter alloc]init];      NSString * realdata = [parser stringWithObject:dicWithSign];      NSString *Stringdata = [NSData AES256EncryptWithPlainText:realdata key:merchantAesKey];      //step7 使用 RSA 加密 merchantAesKey 生成密钥密文:      NSString *Stringencryptkey = [t encryptByRsa:merchantAesKey withKeyType:KeyTypePublic];      [resultDic setObject:Stringdata forKey:@"data"];      [resultDic setObject:Stringencryptkey forKey:@"encryptKey"];

项目主页:http://www.open-open.com/lib/view/home/1441704774649

 本文由用户 jopen 自行上传分享,仅供网友学习交流。所有权归原作者,若您的权利被侵害,请联系管理员。
 转载本站原创文章,请注明出处,并保留原始链接、图片水印。
 本站是一个以用户分享为主的开源技术平台,欢迎各类分享!
 本文地址:https://www.open-open.com/lib/view/open1441704774649.html
iOS开发 移动开发 AES-RSA-For-iOS