aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/sisu/v5/ao_hash_digest.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sisu/v5/ao_hash_digest.rb')
-rw-r--r--lib/sisu/v5/ao_hash_digest.rb24
1 files changed, 17 insertions, 7 deletions
diff --git a/lib/sisu/v5/ao_hash_digest.rb b/lib/sisu/v5/ao_hash_digest.rb
index 3f372893..1c20671f 100644
--- a/lib/sisu/v5/ao_hash_digest.rb
+++ b/lib/sisu/v5/ao_hash_digest.rb
@@ -65,7 +65,7 @@ module SiSU_AO_Hash
class ObjectDigest
def initialize(md,data,env=nil)
@md,@data,@env=md,data,env
- @env ||=SiSU_Env::InfoEnv.new(@md.fns)
+ @env ||=SiSU_Env::InfoEnv.new(@md.fns,@md)
end
def object_digest
# 1. clean/stripped text without any markup, paragraph, headings etc. without endnotes
@@ -74,11 +74,11 @@ module SiSU_AO_Hash
# [digests should not include other digests]
data=@data.compact
@tuned_file=[]
- sha_ =(@env.digest.type=='sha256' ? true : false)
+ sha_ =@env.digest(@md.opt).type
begin
sha_ ? (require 'digest/sha2') : (require 'digest/md5')
rescue LoadError
- SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error((sha_ ? 'digest/sha2' : 'digest/md5') + ' NOT FOUND')
+ SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error(sha_ + ' NOT FOUND')
end
data.each do |t_o|
unless t_o.obj.is_a?(Array)
@@ -88,11 +88,16 @@ module SiSU_AO_Hash
&& t_o.of !=:comment \
&& t_o.of !=:layout) \
&& t_o.ocn.is_a?(Fixnum)
- if sha_
+ case sha_
+ when :sha512
+ for hash_class in [ Digest::SHA512 ]
+ @tuned_file << stamped(t_o,hash_class)
+ end
+ when :sha256
for hash_class in [ Digest::SHA256 ]
@tuned_file << stamped(t_o,hash_class)
end
- else
+ when :md5
for hash_class in [ Digest::MD5 ]
@tuned_file << stamped(t_o,hash_class)
end
@@ -111,10 +116,15 @@ module SiSU_AO_Hash
if en_plus =~/#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]}/
t_o_txt,en_open,en_txt,en_close=/(.*?)(#{Mx[:en_a_o]}|#{Mx[:en_b_o]})(.+?)(#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/m.match(en_plus)[1..4]
stripped_en=SiSU_TextRepresentation::Alter.new(en_txt).strip_clean_of_markup
- digest_en_strip=if @env.digest.type =~/sha256/
+ digest_en_strip=case @env.digest(@md.opt).type
+ when :sha512
+ Digest::SHA512.hexdigest(stripped_en)
+ when :sha256
Digest::SHA256.hexdigest(stripped_en)
- else
+ when :md5
Digest::MD5.hexdigest(stripped_en)
+ else
+ Digest::SHA256.hexdigest(stripped_en)
end
t_o_txt + en_open + en_txt + Mx[:id_o] + digest_en_strip + Mx[:id_c] + en_close
else STDERR.puts "Error Exception - problem encountered with:\n#{en_plus}" #arbitrary exception, tidy up