Feature #4042
closedString#crypt shoud not accepted "\x00" as a salt.
Description
=begin
I noticed if the salt contains non ascii value, the result is platform dependant.
Especially, the salt start with "\x00", the result is empty string on Linux.
On Linux,
ruby 1.9.3dev (2010-11-04 trunk 29682) [i686-linux]
irb(main):001:0> "foo".crypt("\x00\x00")
=> ""
irb(main):002:0> "foo".crypt("\x00\x01")
=> ""
irb(main):003:0> "foo".crypt("\x01\x00")
=> "\x01\x01Rqd3mnMHSeY"
irb(main):004:0> "foo".crypt("\x01\x01")
=> "\x01\x01EV3MX6qznTs"
irb(main):005:0> "foo".crypt("ab")
=> "abQ9KY.KfrYrc"
On Windows,
ruby 1.9.3dev (2010-11-09 trunk 29737) [i386-mswin32_90]
irb(main):001:0> "foo".crypt("\x00\x00")
=> "..XXIp7/c78Qo"
irb(main):002:0> "foo".crypt("\x00\x01")
=> ".\x01XXIp7/c78Qo"
irb(main):003:0> "foo".crypt("\x01\x00")
=> "\x01.XXIp7/c78Qo"
irb(main):004:0> "foo".crypt("\x01\x01")
=> "\x01\x01XXIp7/c78Qo"
irb(main):005:0> "foo".crypt('ab')
=> "abQ9KY.KfrYrc"
I think that String#crypt shoud raise ArgError if "\x00" used as a salt.
=end
Updated by naruse (Yui NARUSE) about 14 years ago
- Status changed from Open to Rejected
=begin
String#crypt is the wrapper of crypt(3).
POSIX says crypt(3)'s algorithm is implementation-defined.
http://www.opengroup.org/onlinepubs/9699919799/functions/crypt.html
So your expectation, some of String#crypt's behavior is platform-independent, is wrong.
Moreover new applications should use digests.
=end