Revert OpenSSL conversion for SHA1-based hashes

Update local_encoding_functions to avoid FrozenError on encoding modules
This commit is contained in:
Tom Harrison
2023-01-10 10:33:21 +00:00
parent 018bae6d75
commit 1205a48397
5 changed files with 5 additions and 9 deletions

View File

@@ -25,7 +25,7 @@ class EncodingFunctions
utf8 = []
value.map {|element|
if element.is_a? String
utf8 << element.force_encoding('UTF-8')
utf8 << element.dup.force_encoding('UTF-8')
elsif element.is_a? Hash
utf8 << EncodingFunctions::hash_to_utf8(element)
elsif element.is_a? Array

View File

@@ -1,6 +1,5 @@
#!/usr/bin/ruby
require_relative '../../../../../lib/objects/local_hash_encoder.rb'
require 'openssl'
class SHA1Encoder < HashEncoder
def initialize
@@ -9,7 +8,7 @@ class SHA1Encoder < HashEncoder
end
def hash_function(string)
OpenSSL::Digest::SHA1.new.hexdigest(string)
Digest::SHA1.hexdigest(string)
end
end

View File

@@ -1,6 +1,5 @@
#!/usr/bin/ruby
require_relative '../../../../../lib/objects/local_hash_encoder.rb'
require 'openssl'
class SHA256Encoder < HashEncoder
def initialize
@@ -9,7 +8,7 @@ class SHA256Encoder < HashEncoder
end
def hash_function(string)
OpenSSL::Digest::SHA256.new.hexdigest(string)
Digest::SHA256.hexdigest(string)
end
end

View File

@@ -1,6 +1,5 @@
#!/usr/bin/ruby
require_relative '../../../../../lib/objects/local_hash_encoder.rb'
require 'openssl'
class SHA384Encoder < HashEncoder
def initialize
@@ -9,7 +8,7 @@ class SHA384Encoder < HashEncoder
end
def hash_function(string)
OpenSSL::Digest::SHA384.new.hexdigest(string)
Digest::SHA384.hexdigest(string)
end
end

View File

@@ -1,6 +1,5 @@
#!/usr/bin/ruby
require_relative '../../../../../lib/objects/local_hash_encoder.rb'
require 'openssl'
class SHA512Encoder < HashEncoder
def initialize
@@ -9,7 +8,7 @@ class SHA512Encoder < HashEncoder
end
def hash_function(string)
OpenSSL::Digest::SHA512.new.hexdigest(string)
Digest::SHA512.hexdigest(string)
end
end