Sha256: e09cdafaedcf286cf417f6516d9963b8a3ada3d9ab71accf5b566b31bfd38918

Contents?: true

Size: 990 Bytes

Versions: 6

Compression:

Stored size: 990 Bytes

Contents

#
# Author:: Adam Jacob (<adam@opscode.com>)
# Copyright:: Copyright (c) 2008 Opscode, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# 
#     http://www.apache.org/licenses/LICENSE-2.0
# 
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

require 'digest/sha2'

class Chef
  module Mixin
    module Checksum

      def checksum(file)
        digest = Digest::SHA256.new
        fh = ::File.open(file)
        fh.each do |line|
          digest.update(line)
        end
        fh.close
        digest.hexdigest
      end
      
    end
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
chef-0.7.16 lib/chef/mixin/checksum.rb
giraffesoft-chef-0.7.16 lib/chef/mixin/checksum.rb
giraffesoft-chef-0.7.15 lib/chef/mixin/checksum.rb
chef-0.7.14 lib/chef/mixin/checksum.rb
chef-0.7.12 lib/chef/mixin/checksum.rb
chef-0.7.10 lib/chef/mixin/checksum.rb