On the internet to find a lot of RC4 and decryption, OC write encryption is mainly http://www.cocoachina.com/bbs/read.php?tid-77608.html this article. After I used, and our PHP can not correspond, he encrypted after I decrypt the wrong, I encrypt his decryption is not right. So, I wrote it myself again.
1. First, download a OpenSSL library and put the library on the desktop
2. Create a new project and import two libraries in Lib-ios: LIBCRYPTO.A and LIBSSL.A, open Project, Build Setting->header Search Paths add Field/users/xxxx/desktop/ Openssl-master/include-ios,library Search Paths Add field $ (project_dir)/project name/folder name;
3. Import zhyrc4.c, Zhyrc4.h, base64.c, Base64.h.
4. Use: Import header file # include "Zhyrc4.h",
Encryption
+ (NSString *) Encode: (NSString *) data{
Char *pwd = "@ndroid!os";
const char * cData = [data utf8string];
char *base64_data = NULL;
Zhyencode (PWD, CDATA, strlen (CDATA), &base64_data);
NSString * str = [NSString stringwithutf8string:base64_data];
if (base64_data) {
Free (base64_data);
Base64_data = NULL;
}
return str;
}
+ (NSString *) decode: (NSString *) data{
Char *pwd = "@ndroid!os";
const char * cData = [data utf8string];
Char *data1=null;
Zhydecode (pwd, CData, &data1);
NSString * str = [NSString stringwithutf8string:data1];
if (data1) {
Free (DATA1);
Data1 = NULL;
}
return str;
}
That's it. RC4 plus decryption are the same method, if you do not need base64 encryption, in ZHYRC4.C, zhyrc4.h change on the line, so easy.
File is too big, give a link: Link: http://pan.baidu.com/s/1nvpgkdz Password: n82a
iOS version of RC4-BASE64 encryption decryption