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?



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:
http://lists.apple.com/mailman/options/xcode-users/email@hidden

This email sent to 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.