Re: XCode 2.1 - different result from crypt in deployment and debug?
Re: XCode 2.1 - different result from crypt in deployment and debug?
- Subject: Re: XCode 2.1 - different result from crypt in deployment and debug?
- From: Alexey Proskuryakov <email@hidden>
- Date: Thu, 09 Jun 2005 11:39:22 +0400
On 08.06.2005 17:29, "Rick Jansen" <email@hidden> wrote:
> Below's the code. I must have done something wrong...
Yes, you are working with random locations in memory. When the compiler
gave an error about incorrect pointer types, you shouldn't have shut it up
with a cast. Also, don't forget about the trailing zero in C strings.
> char pw[8];
> [Password getCString:(char *)&pw maxLength:8];
Should be:
char pw[9];
[Password getCString:pw maxLength:8];
Also, getCString:maxLength: is deprecated in 10.4 (they don't say what to
use instead; I recommend CFStringGetCString() ;) )
> char seed[2];
> [Seed getCString:(char *)&seed maxLength:2];
Replicated several more times...
> // Crypt
> char encrypted[256]; // Assume 256 is enough
> char *encryptedPtr;
> encryptedPtr = (char *)&encrypted;
> encryptedPtr = crypt( (char *)&pw, (char *)&seed );
>
> // Convert crypted C-string to NSString
> NSString *Encoded = [[NSString alloc] initWithCString:encryptedPtr];
> NSLog(@"CheckRegisterCode: encoded %@ is: %@", Password, Encoded);
>
> // more code...
> return NO;
> }
- WBR, Alexey Proskuryakov
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden