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