Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: XCode 2.1 - different result from crypt in deployment and debug?



Alexey Proskuryakov zee op 9/6/05 09:39:
> 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.

Argh, I've been away from this kind of thing too long, I completely
overlooked it and messed up. It works now. Thanks!

    NSString *Seed = [Password substringToIndex:1];  // 2st char pw
    Seed = [Seed stringByAppendingString:[Password
substringFromIndex:([Password length]-1) ]];    // Append last char pw
    NSLog(@"CheckRegisterCode: pw=%@ seed=%@",
Password, Seed);

    // Convert Unicode NSString to C-string. 8 chars max.
    char pw[9];
    if ([Password length] > 8) Password = [Password substringToIndex:8];

    [Password getCString:pw maxLength:8];

    // Convert Unicode seed (2 chars)
    char seed[3];
    [Seed getCString:seed maxLength:2];

    // Crypt and convert crypted C-string to NSString
    NSString *Encoded =
        [[NSString alloc] initWithCString:crypt(pw,seed)];

    NSLog(@"PreferencesController: CheckRegisterCode: encoded %@ is:
%@", Password, Encoded);

Rick (shamefaced)


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/xcode-users/email@hidden

This email sent to email@hidden

References: 
 >Re: XCode 2.1 - different result from crypt in deployment and debug? (From: Alexey Proskuryakov <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.