How crypt works

Hi,
can anybody gimme a example how crypt works with ruby, could not find
anything anywhere, just this info below, however I get all kind of
errors with my tries: Where I’m failing???

Tx
Dai

irb(main):011:0* “the_string”.crypt(aa)
NameError: undefined local variable or method aa' for main:Object from (irb):11 from /usr/local/bin/irb:12:in
irb(main):012:0> exit
[backman@minsk ~]$ ruby -v
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-linux]

crypt str.crypt( aString ) -> aString
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./].

Il giorno Thu, 9 Feb 2012 06:38:18 +0900
Vic T. [email protected] ha scritto:

NameError: undefined local variable or method `aa’ for main:Object
library function crypt. The argument is the salt string, which should be
two characters long, each character drawn from [a-zA-Z0-9./].

I never used crypt, but I’m almost sure you need to quote the aa so that
it
is interpreted as a string rather than a variable name/method call:

“the_string”.crypt(‘aa’)

Stefano

You tried to pass a variable named ‘aa’ into the method.

1.9.2p290 :001 > “the_string”.crypt(aa)
NameError: undefined local variable or method aa' for main:Object from (irb):1 from /Users/steve/.rvm/rubies/ruby-1.9.2-p290/bin/irb:16:in
1.9.2p290 :002 > “the_string”.crypt(“aa”)
=> “aaA8bm5HCtDYk”

See?

On Wed, Feb 8, 2012 at 3:38 PM, Vic T. [email protected] wrote:

NameError: undefined local variable or method aa' for main:Object from (irb):11 from /usr/local/bin/irb:12:in
irb(main):012:0> exit
[backman@minsk ~]$ ruby -v
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-linux]

aa should be a two-character string – you need to put it in quotes.
When it’s outside of quotes, Ruby assumes you intend it as a local
variable or method name.

Thanks, all guys !

Thanks god I did not ask this question my professor, it was really stu…

Best
Dai