1、DES加密
-(NSString*)encryptDES:(NSString*)plainText{
NSString *key = @"AsdFGhjKLqWErtYuioPZxcvB";
NSString*iv =@"12345678";
NSString*ciphertext =nil;
NSData *textData = [plainText dataUsingEncoding:NSUTF8StringEncoding];
NSUIntegerdataLength = [textDatalength];
size_tbufferSize = dataLength +kCCBlockSizeDES;
void*buffer =malloc(bufferSize);
memset(buffer,0,sizeof(char));
size_tnumBytesEncrtpted =0;
CCCryptorStatuscryptStatus =CCCrypt(kCCEncrypt,kCCAlgorithmDES,kCCOptionPKCS7Padding, [keyUTF8String],kCCBlockSizeDES, [ivUTF8String], [textDatabytes], dataLength, buffer, bufferSize, &numBytesEncrtpted);
if(cryptStatus ==kCCSuccess){
NSData*data = [NSDatadataWithBytes:(constvoid*)bufferlength:(NSUInteger)numBytesEncrtpted];
ciphertext = [GTMCCBBase64stringByEncodingData:data];
}
returnciphertext;
}