Page 1 of 1

iphone onRandomKey()

Posted: 28 Sep 2009, 18:28
by aw2xcd
Hi Guys,

I'm not quite sure if I'm reading the random key properly, because I'm using the right user name and password but still can't login.

Code: Select all

- (void) onRandomKey:(INFSmartFoxSFSEvent *)evt 
{
	NSString *md5ma_pass = [self md5ma:@"1"];

	//NSString *key = [[NSString alloc] initWithUTF8String: [[evt.params objectForKey:@"key"] UTF8String]]; 
	//NSString *key = [[NSString alloc] initWithString: [evt.params objectForKey:@"key"]]; 
	//NSString *key = [[NSString alloc] initWithData: [evt.params objectForKey:@"key"] encoding:NSASCIIStringEncoding ]; 
	NSString *key = [[NSString alloc] initWithData: [evt.params objectForKey:@"key"] encoding:NSUTF8StringEncoding ]; 
	
	
	
	NSString *md5ma_pass_key = [md5ma_pass stringByAppendingString:  key];

	[smartFox login:smartFox.defaultZone name: @"1" pass: [self md5ma: md5ma_pass_key]];	
}

These are the replys I get from the server,

Code: Select all

<msg t='sys'><body action='rndK' r='-1'><k>gVtS\L^eAkmNiOd_J\</k></body></msg>

<msg t='sys'><body action='rndK' r='-1'><k>AoLzBKOzirMa[vetTcK</k></body></msg>
Is this what the key should look like? Any advice would be nice!

cheers,
chris

Posted: 30 Sep 2009, 15:12
by aw2xcd
figured it out finally, the sfs extention was returning md5 in lower case and my cocoa md5 function was returning upper case;

Code: Select all

- (void) onRandomKey:(INFSmartFoxSFSEvent *)evt 
{
	NSString *md5ma_pass = [[self md5ma:@"pass1"] lowercaseString ];
	NSString *key = [[NSString alloc] initWithString: [evt.params objectForKey:@"key"]]; 	
	
	
	NSString *md5ma_pass_key = [md5ma_pass stringByAppendingString:  key];

	[smartFox login:@"room1" name: @"user1" pass: [[self md5ma: md5ma_pass_key] lowercaseString ]];	
}