summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--lib/axlsx/workbook/worksheet/sheet_protection.rb27
1 files changed, 15 insertions, 12 deletions
diff --git a/lib/axlsx/workbook/worksheet/sheet_protection.rb b/lib/axlsx/workbook/worksheet/sheet_protection.rb
index 87d6186f..717e2f8b 100644
--- a/lib/axlsx/workbook/worksheet/sheet_protection.rb
+++ b/lib/axlsx/workbook/worksheet/sheet_protection.rb
@@ -152,18 +152,21 @@ module Axlsx
end
end
- def propper_password=(v)
- @algorithm_name = v == nil ? nil : 'SHA-1'
- @salt_value = @spin_count = @hash_value = v if v == nil
- return if v == nil
- require 'digest/sha1'
- @spin_count = 10000
- @salt_value = Digest::SHA1.hexdigest(rand(36**8).to_s(36))
- @hash_value = nil
- @spin_count.times do |count|
- @hash_value = Digest::SHA1.hexdigest((@hash_value || (@salt_value + v.to_s)) + Array(count).pack('V'))
- end
- end
+ # This block is intended to implement the salt_value, hash_value and spin count as per the ECMA-376 standard.
+ # However, it does not seem to actually work in EXCEL - instead they are using their old retro algorithm shown below
+ # defined in the transitional portion of the speck. I am leaving this code in in the hope that someday Ill be able to
+ # figure out why it does not work, and if Excel even supports it.
+# def propper_password=(v)
+# @algorithm_name = v == nil ? nil : 'SHA-1'
+# @salt_value = @spin_count = @hash_value = v if v == nil
+# return if v == nil
+# require 'digest/sha1'
+# @spin_count = 10000
+# @salt_value = Digest::SHA1.hexdigest(rand(36**8).to_s(36))
+# @spin_count.times do |count|
+# @hash_value = Digest::SHA1.hexdigest((@hash_value ||= (@salt_value + v.to_s)) + Array(count).pack('V'))
+# end
+# end