X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=3rdparty%2Fmodules%2Fstdlib%2Flib%2Fpuppet%2Fparser%2Ffunctions%2Fstr2saltedsha512.rb;h=4d62008b76ebce776530b3850c7bfc7f94c0d228;hb=131e09855e065be940e104d9ab0f18940cc76257;hp=0410c62c135da220a61c60c044161c46c3e3acc4;hpb=407d322498f4fde815abf381007fbecfe5c10b2b;p=mirror%2Fdsa-puppet.git diff --git a/3rdparty/modules/stdlib/lib/puppet/parser/functions/str2saltedsha512.rb b/3rdparty/modules/stdlib/lib/puppet/parser/functions/str2saltedsha512.rb index 0410c62c1..4d62008b7 100644 --- a/3rdparty/modules/stdlib/lib/puppet/parser/functions/str2saltedsha512.rb +++ b/3rdparty/modules/stdlib/lib/puppet/parser/functions/str2saltedsha512.rb @@ -2,15 +2,14 @@ # str2saltedsha512.rb # Please note: This function is an implementation of a Ruby class and as such may not be entirely UTF8 compatible. To ensure compatibility please use this function with Ruby 2.4.0 or greater - https://bugs.ruby-lang.org/issues/10085. # - module Puppet::Parser::Functions - newfunction(:str2saltedsha512, :type => :rvalue, :doc => <<-EOS -This converts a string to a salted-SHA512 password hash (which is used for -OS X versions >= 10.7). Given any simple string, you will get a hex version -of a salted-SHA512 password hash that can be inserted into your Puppet -manifests as a valid password attribute. - EOS - ) do |arguments| + newfunction(:str2saltedsha512, :type => :rvalue, :doc => <<-DOC + This converts a string to a salted-SHA512 password hash (which is used for + OS X versions >= 10.7). Given any simple string, you will get a hex version + of a salted-SHA512 password hash that can be inserted into your Puppet + manifests as a valid password attribute. + DOC + ) do |arguments| require 'digest/sha2' raise(Puppet::ParseError, "str2saltedsha512(): Wrong number of arguments passed (#{arguments.size} but we require 1)") if arguments.size != 1 @@ -22,7 +21,7 @@ manifests as a valid password attribute. end seedint = rand(2**31 - 1) - seedstring = Array(seedint).pack("L") + seedstring = Array(seedint).pack('L') saltedpass = Digest::SHA512.digest(seedstring + password) (seedstring + saltedpass).unpack('H*')[0] end