method

crypt

Importance_2
Ruby latest stable (v1_8_7_72) - 2 notes - Class: String
crypt(p1) public

Applies a one-way cryptographic hash to str by invoking the standard library function crypt. The argument is the salt string, which should be two characters long, each character drawn from [a-zA-Z0-9./].

Show source
Register or log in to add new notes.
May 4, 2009
1 thank

clarification

Via Kenneth Kalmer:

From the man page: If salt is a character string starting with the characters “$id$” followed by a string terminated by “$”: $id$salt$encrypted then instead of using the DES machine, id identifies the encryption method used and this then determines how the rest of the password string is interpreted.

irb session

  =>abNANd1rDfiNc”
  irb(main):002:0>secret”.crypt(”abasasa”)
  =>abNANd1rDfiNc”
  irb(main):003:0>secret”.crypt(”$1$abasasa”)
  =>$1$abasasa$2RZY2vd6E2ZEPSDa0eLec0″
  irb(main):004:0>secret”.crypt(”$1$abasa”)
  =>$1$abasa$ikoKICgwOFdcWgmDl9Asy1″

see http://www.opensourcery.co.za/2009/05/01/quick-nix-shadow-passwords-with-ruby/

February 11, 2010 - (v1_8_6_287 - v1_8_7_72)
0 thanks

Clarification of argument

The description should read:

The argument is the salt string, which must be at least two characters long, each character drawn from [a-zA-Z0-9./].