Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/ExeBy/exe_root.../opt/alt/ruby32/share/ruby
File: digest.rb
# frozen_string_literal: false
[0] Fix | Delete
[1] Fix | Delete
if defined?(Digest) &&
[2] Fix | Delete
/\A(?:2\.|3\.0\.[0-2]\z)/.match?(RUBY_VERSION) &&
[3] Fix | Delete
caller_locations.any? { |l|
[4] Fix | Delete
%r{/(rubygems/gem_runner|bundler/cli)\.rb}.match?(l.path)
[5] Fix | Delete
}
[6] Fix | Delete
# Before Ruby 3.0.3/3.1.0, the gem and bundle commands used to load
[7] Fix | Delete
# the digest library before loading additionally installed gems, so
[8] Fix | Delete
# you will get constant redefinition warnings and unexpected
[9] Fix | Delete
# implementation overwriting if we proceed here. Avoid that.
[10] Fix | Delete
return
[11] Fix | Delete
end
[12] Fix | Delete
[13] Fix | Delete
require 'digest/version'
[14] Fix | Delete
require 'digest/loader'
[15] Fix | Delete
[16] Fix | Delete
module Digest
[17] Fix | Delete
# A mutex for Digest().
[18] Fix | Delete
REQUIRE_MUTEX = Thread::Mutex.new
[19] Fix | Delete
[20] Fix | Delete
def self.const_missing(name) # :nodoc:
[21] Fix | Delete
case name
[22] Fix | Delete
when :SHA256, :SHA384, :SHA512
[23] Fix | Delete
lib = 'digest/sha2'
[24] Fix | Delete
else
[25] Fix | Delete
lib = File.join('digest', name.to_s.downcase)
[26] Fix | Delete
end
[27] Fix | Delete
[28] Fix | Delete
begin
[29] Fix | Delete
require lib
[30] Fix | Delete
rescue LoadError
[31] Fix | Delete
raise LoadError, "library not found for class Digest::#{name} -- #{lib}", caller(1)
[32] Fix | Delete
end
[33] Fix | Delete
unless Digest.const_defined?(name)
[34] Fix | Delete
raise NameError, "uninitialized constant Digest::#{name}", caller(1)
[35] Fix | Delete
end
[36] Fix | Delete
Digest.const_get(name)
[37] Fix | Delete
end
[38] Fix | Delete
[39] Fix | Delete
class ::Digest::Class
[40] Fix | Delete
# Creates a digest object and reads a given file, _name_.
[41] Fix | Delete
# Optional arguments are passed to the constructor of the digest
[42] Fix | Delete
# class.
[43] Fix | Delete
#
[44] Fix | Delete
# p Digest::SHA256.file("X11R6.8.2-src.tar.bz2").hexdigest
[45] Fix | Delete
# # => "f02e3c85572dc9ad7cb77c2a638e3be24cc1b5bea9fdbb0b0299c9668475c534"
[46] Fix | Delete
def self.file(name, *args)
[47] Fix | Delete
new(*args).file(name)
[48] Fix | Delete
end
[49] Fix | Delete
[50] Fix | Delete
# Returns the base64 encoded hash value of a given _string_. The
[51] Fix | Delete
# return value is properly padded with '=' and contains no line
[52] Fix | Delete
# feeds.
[53] Fix | Delete
def self.base64digest(str, *args)
[54] Fix | Delete
[digest(str, *args)].pack('m0')
[55] Fix | Delete
end
[56] Fix | Delete
end
[57] Fix | Delete
[58] Fix | Delete
module Instance
[59] Fix | Delete
# Updates the digest with the contents of a given file _name_ and
[60] Fix | Delete
# returns self.
[61] Fix | Delete
def file(name)
[62] Fix | Delete
File.open(name, "rb") {|f|
[63] Fix | Delete
buf = ""
[64] Fix | Delete
while f.read(16384, buf)
[65] Fix | Delete
update buf
[66] Fix | Delete
end
[67] Fix | Delete
}
[68] Fix | Delete
self
[69] Fix | Delete
end
[70] Fix | Delete
[71] Fix | Delete
# If none is given, returns the resulting hash value of the digest
[72] Fix | Delete
# in a base64 encoded form, keeping the digest's state.
[73] Fix | Delete
#
[74] Fix | Delete
# If a +string+ is given, returns the hash value for the given
[75] Fix | Delete
# +string+ in a base64 encoded form, resetting the digest to the
[76] Fix | Delete
# initial state before and after the process.
[77] Fix | Delete
#
[78] Fix | Delete
# In either case, the return value is properly padded with '=' and
[79] Fix | Delete
# contains no line feeds.
[80] Fix | Delete
def base64digest(str = nil)
[81] Fix | Delete
[str ? digest(str) : digest].pack('m0')
[82] Fix | Delete
end
[83] Fix | Delete
[84] Fix | Delete
# Returns the resulting hash value and resets the digest to the
[85] Fix | Delete
# initial state.
[86] Fix | Delete
def base64digest!
[87] Fix | Delete
[digest!].pack('m0')
[88] Fix | Delete
end
[89] Fix | Delete
end
[90] Fix | Delete
end
[91] Fix | Delete
[92] Fix | Delete
# call-seq:
[93] Fix | Delete
# Digest(name) -> digest_subclass
[94] Fix | Delete
#
[95] Fix | Delete
# Returns a Digest subclass by +name+ in a thread-safe manner even
[96] Fix | Delete
# when on-demand loading is involved.
[97] Fix | Delete
#
[98] Fix | Delete
# require 'digest'
[99] Fix | Delete
#
[100] Fix | Delete
# Digest("MD5")
[101] Fix | Delete
# # => Digest::MD5
[102] Fix | Delete
#
[103] Fix | Delete
# Digest(:SHA256)
[104] Fix | Delete
# # => Digest::SHA256
[105] Fix | Delete
#
[106] Fix | Delete
# Digest(:Foo)
[107] Fix | Delete
# # => LoadError: library not found for class Digest::Foo -- digest/foo
[108] Fix | Delete
def Digest(name)
[109] Fix | Delete
const = name.to_sym
[110] Fix | Delete
Digest::REQUIRE_MUTEX.synchronize {
[111] Fix | Delete
# Ignore autoload's because it is void when we have #const_missing
[112] Fix | Delete
Digest.const_missing(const)
[113] Fix | Delete
}
[114] Fix | Delete
rescue LoadError
[115] Fix | Delete
# Constants do not necessarily rely on digest/*.
[116] Fix | Delete
if Digest.const_defined?(const)
[117] Fix | Delete
Digest.const_get(const)
[118] Fix | Delete
else
[119] Fix | Delete
raise
[120] Fix | Delete
end
[121] Fix | Delete
end
[122] Fix | Delete
[123] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function