Module: Spreadsheet::Excel::Password

Defined in:
lib/spreadsheet/excel/password_hash.rb

Class Method Summary (collapse)

Class Method Details

+ (Object) password_hash(password)

Makes an excel-compatible hash



7
8
9
10
11
# File 'lib/spreadsheet/excel/password_hash.rb', line 7

def password_hash(password)
  hash = 0
  password.chars.reverse_each { |chr| hash = rol15(hash ^ chr[0].ord) }
  hash ^ password.size ^ 0xCE4B
end