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