0

My server login parameters:

username
password (md5 encrypted)
logintype

Return parameter:

userId
username
levelid
mobilenum
email
  • 0 Success
  • 10001 account name can not be empty
  • 10002 account does not exist
  • 10003 password is incorrect
  • 10004 Invalid account
Cœur
  • 37,241
  • 25
  • 195
  • 267
kevin
  • 11
  • 2
  • MD5 is not encryption, it is a hash function. It is not encryption because it is a fine-way function, that is given a hash one can not obtain the original data. Please do some research. – zaph Nov 18 '14 at 11:50

1 Answers1

0

Try this,

#import <CommonCrypto/CommonDigest.h>

NSString *md5(NSString *str) {
    const char *cStr = [str UTF8String];
    unsigned char result[CC_MD5_DIGEST_LENGTH];
    CC_MD5( cStr, strlen(cStr), result );
    return [NSString stringWithFormat:@"%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X",
            result[0], result[1],
            result[2], result[3],
            result[4], result[5],
            result[6], result[7],
            result[8], result[9],
            result[10], result[11],
            result[12], result[13],
            result[14], result[15]
            ];
}

- (IBAction)grabURLInBackground:(id)sender
{
    NSURL *url = [NSURL URLWithString:yourURL];
    ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];

     (md5 encrypted)

    [request addPostValue:@"your username" forKey:@"username"];
    [request addPostValue:md5(@"your password"); forKey:@"password"];
    [request addPostValue:@"your login type" forKey:@"logintype"];
    [request setDelegate:self];
    [request startAsynchronous];
}

- (void)requestFinished:(ASIHTTPRequest *)request
{
    // Use when fetching text data
    NSString *responseString = [request responseString];

    // Use when fetching binary data
    NSData *responseData = [request responseData];
}

- (void)requestFailed:(ASIHTTPRequest *)request
{
    NSError *error = [request error];
}
Neenu
  • 6,848
  • 2
  • 28
  • 54
  • ASIHTTP really should not be used for new work. From the [ASIHTTPRequest page](http://allseeing-i.com/ASIHTTPRequest/): "Please note that I am no longer working on this library - you may want to consider using something else for new projects. :)" The current favored library is [AFNetworking](https://github.com/AFNetworking/AFNetworking). – zaph Nov 18 '14 at 11:46