• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: XCode 2.1 - different result from crypt in deployment and debug?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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: Rick Jansen <email@hidden>
  • Date: Wed, 08 Jun 2005 15:29:16 +0200

email@hidden zee op 8/6/05 06:17:

Chris Espinosa wrote:

> On Jun 7, 2005, at 7:42 AM, Rick Jansen wrote:
>
>> I'm using crypt to encrypt a password, to check against a Perl-
>> generated
>> list of encrypted passwords. Under Xcode 1.5 crypt delivered the same
>> result as Perl, both in deployment and debug mode, but with XCode 2.1
>> the deployment version results in a different encrypted string!

> Since Xcode 1.5 only runs on Panther and Xcode 2.1 requires Tiger,
> are you sure this isn't an OS thing?

On Tiger, with XCode 2.1 the debug and deployment version returns a
different result. The debug version under 2.1 has the correct result,
with the same encrypted result as on Panther and XCode 1.5.

Below's the code. I must have done something wrong...

Rick

The seed is the first and the last char of the original password here.

- (BOOL) CheckRegisterCode:(NSString *)Password
{
  NSString *Seed = [Password substringToIndex:1]; // 1st char of Password
  Seed = [Seed stringByAppendingString:[Password
                  substringFromIndex:([Password length]-1) ]];
         // Append last char of Password

  NSLog(@"CheckRegisterCode: pw=%@ seed=%@", Password, Seed);

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

  // First 8 characters of Password (restrict length)
  [Password getCString:(char *)&pw maxLength:8];

  // Convert Unicode seed (2 chars) to c-string
  char seed[2];
  [Seed getCString:(char *)&seed maxLength:2];

  // 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;
}

Result (debug) OK:
CheckRegisterCode: pw=abracada seed=aa
CheckRegisterCode: encoded abracada is: aaB/egd9mRItM

Result (deployment) WRONG:
CheckRegisterCode: pw=abracada seed=aa
CheckRegisterCode: encoded abracada is: aaQSqAReePlq6









 _______________________________________________
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

  • Follow-Ups:
    • Re: XCode 2.1 - different result from crypt in deployment and debug?
      • From: Alexey Proskuryakov <email@hidden>
  • Prev by Date: Xcode 2.1 --- strings passed as -DMY_STRING="mystring"
  • Next by Date: Re: Duplicate warnings
  • Previous by thread: Re: XCode 2.1 - different result from crypt in deployment and debug?
  • Next by thread: Re: XCode 2.1 - different result from crypt in deployment and debug?
  • Index(es):
    • Date
    • Thread