1

I have the OpenSSL library working fine on my iPhone, and can create hashes etc... I was just wondering how I'd create a salted password within the app so it matches the output of this:

openssl passwd -crypt -salt xxxxxxxxxxxx password

I'm looking for a 'passwd' function within the library but can't seem to find one...

Thanks!

jww
  • 97,681
  • 90
  • 411
  • 885
a1phanumeric
  • 814
  • 2
  • 12
  • 29
  • Ok I figured it out. I didn't realise there was a 'crypt()' function available which already does what I want. For others, just use this: const char *passwd = crypt(password, salt); – a1phanumeric Nov 09 '11 at 12:32

1 Answers1

0

Here's a1phanumeric answer moved into an answer block:

Ok I have the answer... You simply need to do the following:

const char *password = [[NSString stringWithFormat:@"passwordstring"] UTF8String];
const char *salt = [[NSString stringWithFormat:@"saltstring"] UTF8String];

const char *passwd = crypt(password, salt);

NSString *theToken = [NSString stringWithUTF8String:passwd];

NSLog(@"%@", theToken);

EZMode.

jww
  • 97,681
  • 90
  • 411
  • 885