Module: Aws::Checksums Private

Defined in:
lib/aws-sdk-core/checksums.rb

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Constant Summary collapse

CHUNK_SIZE =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

one MB

1 * 1024 * 1024

Class Method Summary collapse

Class Method Details

.md5(value) ⇒ String<MD5>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

  • value (File, Tempfile, IO#read, String)

Returns:

  • (String<MD5>)


28
29
30
31
32
33
34
35
36
37
38
# File 'lib/aws-sdk-core/checksums.rb', line 28

def md5(value)
  if (File === value || Tempfile === value) && !value.path.nil? && File.exist?(value.path)
    Base64.encode64(OpenSSL::Digest::MD5.file(value).digest).strip
  elsif value.respond_to?(:read)
    md5 = OpenSSL::Digest::MD5.new
    update_in_chunks(md5, value)
    Base64.encode64(md5.digest).strip
  else
    Base64.encode64(OpenSSL::Digest::MD5.digest(value)).strip
  end
end

.sha256_hexdigest(value) ⇒ String<SHA256 Hexdigest>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

  • value (File, Tempfile, IO#read, String)

Returns:

  • (String<SHA256 Hexdigest>)


14
15
16
17
18
19
20
21
22
23
24
# File 'lib/aws-sdk-core/checksums.rb', line 14

def sha256_hexdigest(value)
  if (File === value || Tempfile === value) && !value.path.nil? && File.exist?(value.path)
    OpenSSL::Digest::SHA256.file(value).hexdigest
  elsif value.respond_to?(:read)
    sha256 = OpenSSL::Digest::SHA256.new
    update_in_chunks(sha256, value)
    sha256.hexdigest
  else
    OpenSSL::Digest::SHA256.hexdigest(value)
  end
end