diff options
| author | Zsolt Kozaroczy <[email protected]> | 2023-07-05 14:17:33 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-07-05 14:17:33 +0200 |
| commit | c7be63637220c57eb1b8d3afcff77a49aaa7a3ef (patch) | |
| tree | 7b34212665e55d7a2b202de843aa37de571a25e7 /lib | |
| parent | d84f333fc3115025ddbc38c274cd6b2e818b4154 (diff) | |
| parent | d52600dfb373323641c95c3c9be952c32fee8a1a (diff) | |
| download | caxlsx-c7be63637220c57eb1b8d3afcff77a49aaa7a3ef.tar.gz caxlsx-c7be63637220c57eb1b8d3afcff77a49aaa7a3ef.zip | |
Merge pull request #293 from tagliala/chore/fix-offenses-in-sheet-protection
Fix offenses in sheet protection
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/axlsx/workbook/worksheet/sheet_protection.rb | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/axlsx/workbook/worksheet/sheet_protection.rb b/lib/axlsx/workbook/worksheet/sheet_protection.rb index ce39b1b4..abf5e452 100644 --- a/lib/axlsx/workbook/worksheet/sheet_protection.rb +++ b/lib/axlsx/workbook/worksheet/sheet_protection.rb @@ -87,25 +87,25 @@ module Axlsx encoded_password = encode_password(password) password_as_hex = [encoded_password].pack("v") - password_as_string = password_as_hex.unpack("H*").first.upcase + password_as_string = password_as_hex.unpack1("H*").upcase password_as_string[2..3] + password_as_string[0..1] end # Encodes a given password # Based on the algorithm provided by Daniel Rentz of OpenOffice. - # http://www.openoffice.org/sc/excelfileformat.pdf, Revision 1.42, page 115 (21.05.2012) + # https://www.openoffice.org/sc/excelfileformat.pdf, Revision 1.42, page 115 (21.05.2012) # @return [String] def encode_password(password) i = 0 - chars = password.split("") + chars = password.chars count = chars.size chars.collect! do |char| i += 1 - char = char.unpack('c')[0] << i # ord << i + char = char.unpack1('c') << i # ord << i low_15 = char & 0x7fff - high_15 = char & 0x7fff << 15 + high_15 = char & (0x7fff << 15) high_15 = high_15 >> 15 low_15 | high_15 end |
