Puppet Function: stdlib::crc32
- Defined in:
- lib/puppet/functions/stdlib/crc32.rb
- Function type:
- Ruby 4.x API
Overview
Run a CRC32 calculation against a given value.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/puppet/functions/stdlib/crc32.rb', line 11 Puppet::Functions.create_function(:'stdlib::crc32') do # @param my_data The ScalarData to evaluate # @example Check a simple string value # stdlib::crc32('my string') == '18fbd270' # @example Check a Sensitive datatype # stdlib::crc32(sensitive('my string')) == '18fbd270' # @example Check a number # stdlib::crc32(100.0) == 'a3fd429a' # stdlib::crc32(100.00000) == 'a3fd429a' # @return String dispatch :crc32 do param 'Variant[ScalarData, Sensitive[ScalarData], Binary, Sensitive[Binary]]', :my_data return_type 'String' end def crc32(my_data) Zlib.crc32(my_data.unwrap.to_s).to_s(16).downcase rescue StandardError Zlib.crc32(my_data.to_s).to_s(16).downcase end end |