From b97a142300e8b53e574e0e7ac6500fd177d09d68 Mon Sep 17 00:00:00 2001 From: Billy Newman Date: Thu, 12 Mar 2015 08:48:49 -0600 Subject: [PATCH] Use OpenSSL lib to generate salt OpenSSL::Random.random_bytes should give the correct number of bytes for salt. ```bash irb(main):013:0> salt = OpenSSL::Random.random_bytes(6) => "S\xAFJ&\x15\x8D" ``` irb(main):014:0> salt.bytes.to_s => "[83, 175, 74, 38, 21, 141]" --- lib/hashpasswd.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/hashpasswd.rb b/lib/hashpasswd.rb index 15070af..657b310 100644 --- a/lib/hashpasswd.rb +++ b/lib/hashpasswd.rb @@ -27,7 +27,7 @@ def self.createhash(password, options={}) @delimeter = options[:delimter] || ':' @digest = options[:digest] || 'SHA1' - salt = SecureRandom.base64(@salt_byte_size) + salt = OpenSSL::Random.random_bytes(@salt_byte_size) pbkdf2 = OpenSSL::PKCS5::pbkdf2_hmac( password, salt,