标签:ios rsa ios openssl openssl
1.需要后台提供.pem格式的Openssl公钥文件,也可以自己制作。具体请参考:http://www.qmailer.net/archives/216.html(OpenSSL密钥相关命令)
char *my_encrypt(const char *str,const char *path_key){
char *p_en;RSA_public_encrypt(len, plainBuffer, cipherBuffer, p_rsa, RSA_PKCS1_PADDING);
return cipherBuffer;
}
2.也可以尝试:
- (NSString *)encryptWithString:(NSString *)content
{
NSData *publicKey = [NSData dataFromBase64String:RSA_KEY_BASE64];
NSData *usernamm = [content dataUsingEncoding: NSUTF8StringEncoding];
NSData *newKey= [SecKeyWrapper encrypt:usernamm publicKey:publicKey];
NSString *result = [newKey base64EncodedString];
return result;
}
参考链接:http://www.cnblogs.com/aLittleBitCool/archive/2011/09/22/2185418.html
http://www.qmailer.net/archives/216.html
版权声明:本文为博主原创文章,未经博主允许不得转载。
ios客户端RSA公钥加密 .net后台私钥解密解决方案(基于Openssl)
标签:ios rsa ios openssl openssl
原文地址:http://blog.csdn.net/zhouleizhao/article/details/47169415