Problem:
When I do user login, the background API needs to MD5 the encryption of the number and request time of the merged strings, so on the GitHub to find an encrypted frame, link: https://github. (ox) Com/paulery2014/cocoasecurity, I wrote a small demo myself to make it easy for everyone to use.
How to use:
Download the cocoasecurity framework to the local, import the Base64 and cocoasecurity 4 files, and then in the need to call the. m file import "CocoaSecurity.h" header file
Various ways to encrypt the source code:
Signature Algorithm (MD5, SHA1, HMAC)//String MD5 encryption Cocoasecurityresult *result_md5 = [cocoasecurity md5:@] Liuxiaofei
_md5 "];
String SHA1 encryption Cocoasecurityresult *RESULT_SHA1 = [cocoasecurity sha1:@ "LIUXIAOFEI_SHA1"];
String SHA256 encryption Cocoasecurityresult *result_sha256 = [cocoasecurity sha256:@ "liuxiaofei_sha256"];
Print hash (md5,sha1,sha256) after the encryption of the character difference NSLog (@ "MD5 encrypted string is hex:%@", Result_md5.hex);
NSLog (@ "MD5 encrypted string is hexlower:%@", result_md5.hexlower);
NSLog (@ "MD5 encrypted string is base64:%@", result_md5.base64);
NSLog (@ "SHA1 encrypted string is hex:%@", Result_sha1.hex);
NSLog (@ "SHA1 encrypted string is hexlower:%@", result_sha1.hexlower);
NSLog (@ "SHA1 encrypted string is base64:%@", result_sha1.base64);
NSLog (@ "SHA256 encrypted string is hex:%@", Result_sha256.hex);
NSLog (@ "SHA256 encrypted string is hexlower:%@", result_sha256.hexlower);
NSLog (@ "SHA256 encrypted string is base64:%@", result_sha256.base64); Symmetric encryption Algorithm (3DS, AES)/*AES encryption: * Advanced Encryption Standard * is the next generation of encryption algorithm standard, fast, security level high *aes standard one implementation is  
rijndael algorithm */Cocoasecurityresult *result_aes = [cocoasecurity aesencrypt:@ "Liuxiaofei" key:@ "TestKey"];
NSLog (@ "AES encrypted string:%@", Result_aes.hex);
NSLog (@ "AES encrypted string:%@", result_aes.hexlower);
NSLog (@ "AES encrypted string:%@", result_aes.base64);
Asymmetric Encryption Algorithm (data volume comparison hours)//Rsa....blablabla