开发者

Unix crypt() function in smalltalk/pharo

开发者 https://www.devze.com 2023-01-03 16:59 出处:网络
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

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 i开发者_高级运维nvoke external code, if it is required (and there's a package in SqueakMap that makes the trick in pharo).

Thanks.


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


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


There is the PasswordHashingFFI package in the Cryptography repository that uses FFI to access the crypt(3) library on linux.

Its here:

http://www.squeaksource.com/Cryptography.html

Use is like

CryptLinuxFFI sha256:'1234'


OSProcess can be used to call any external program. Have a look at http://book.pharo-project.org/book/PharoTools/OSProcess/

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号