Data encryption plays an important role in the software development process, and some companies may have their own internal design algorithms when encrypting, and in this regard do not want to waste too much effort to consider using third-party provided encryption algorithm, such as AES encryption algorithm, This article describes the open source Chinese iOS client using the ASE algorithm encryption password;
AES GitHub Https://github.com/Gurpartap/AESCrypt-ObjC
For a larger project we may not know where a class library or method is used, but the smart Xcode provides us with a global search function that we can search for in the whole project. For example, I don't know where AES is used, but if you use this class library It will definitely refer to its header file, we search for Aescrypt
Then, in addition to the class library itself, only the Config class contains AESCrpt.h, only two methods are used.
The use of AES is very simple, first to add a header file #import "AESCrypt.h", using the example
-(void) test{
NSString *pwdKey = @
"新风作浪"
;
NSString *password = @
"duxinfeng123456"
;
NSString *encryptedPWD = [AESCrypt encrypt:password password:pwdKey];
NSString *decryptedPWD = [AESCrypt decrypt:encryptedPWD password:pwdKey];
NSLog(@
"加密后密码:%@ 解密后密码: %@"
,encryptedPWD,decryptedPWD);}
Print Result: infeng123456
Cryptographic decryption method function prototype, the two parameters passed the first is the encrypted data, the second is the key to encrypt the data, the decryption time also need this key to decrypt the encrypted data
1.
+ (NSString *)encrypt:(NSString *)message password:(NSString *)password;
2.
+ (NSString *)decrypt:(NSString *)base64EncodedString password:(NSString *)password;
IOS AES encrypted third-party libraries