Search code examples
smalltalkpharo

Unix crypt() function in smalltalk/pharo


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.


Solution

  • 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