Skip to content

Commit a1e9c98

Browse files
Merge pull request #326 from pvdb/fix_attribute_value_warning
Make the `generate()` method more idiomatic...
2 parents 30b5db4 + 34d7c32 commit a1e9c98

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

Diff for: lib/net/ldap/password.rb

+3-5
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,18 @@ class << self
1919
# * Should we provide sha1 as a synonym for sha1? I vote no because then
2020
# should you also provide ssha1 for symmetry?
2121
#
22-
attribute_value = ""
2322
def generate(type, str)
2423
case type
2524
when :md5
26-
attribute_value = '{MD5}' + Base64.encode64(Digest::MD5.digest(str)).chomp!
25+
'{MD5}' + Base64.encode64(Digest::MD5.digest(str)).chomp!
2726
when :sha
28-
attribute_value = '{SHA}' + Base64.encode64(Digest::SHA1.digest(str)).chomp!
27+
'{SHA}' + Base64.encode64(Digest::SHA1.digest(str)).chomp!
2928
when :ssha
3029
salt = SecureRandom.random_bytes(16)
31-
attribute_value = '{SSHA}' + Base64.encode64(Digest::SHA1.digest(str + salt) + salt).chomp!
30+
'{SSHA}' + Base64.encode64(Digest::SHA1.digest(str + salt) + salt).chomp!
3231
else
3332
raise Net::LDAP::HashTypeUnsupportedError, "Unsupported password-hash type (#{type})"
3433
end
35-
return attribute_value
3634
end
3735
end
3836
end

0 commit comments

Comments
 (0)