views:

51

answers:

2

Hello,

I want to encode passwords for UNIX accounts using the crypt function. I'm using pharo 1.0. I tried to install the crypto package from squeakmap, but it gaves me an error and the package seem to get partially installed (categories without class).

How can I get my password crypted? I'm willing to invoke external code, if it is required (and there's a package in SqueakMap that makes the trick in pharo).

Thanks.

+3  A: 

Look if you have a category System-Digital Signatures in your image, with a class SecureHashAlgorithm. You can then hash your password as follows:

(SecureHashAlgorithm new hashMessage: 'my password') asString
Janko Mivšek
Thanks!In fact, I do have that class. It gives me: (SecureHashAlgorithm new hashMessage: 'my password') asString. '930408691521612642154581053007002882786966762294'But, I need the hashed password for unix accounts, so they must be in one of the traditional crypt formats: {crypt}0R9nvENe5JUlE {crypt}$1$8xbtm8Xw$G4HYuFl2fPRUgUBge26CN/Is there a method for this?Thanks again.
jdinuncio
Above class uses SHA hash algorithm. Which algorithm uses crypt these days? Another possibility would be to call some external program with appropriate parameters, using OSProcess class.
Janko Mivšek
+3  A: 

In Pharo check the category: System-Hashing.

There you have MD5 and SHA.

Classes: SHA1, MD5NonPrimitive, MD5.

Those classes were extracted from the crypto package from squeaksource, and make them work in Pharo. Then MD5 and SHA were integrated in the core.

Cheers

Mariano Peck