def password_hash(pwd)
      hsh = 0
      pwd.reverse.each_char { |c|
        hsh = hsh ^ c.ord
        hsh = hsh << 1
        hsh -= 0x7fff if hsh > 0x7fff
      }

      (hsh ^ pwd.length ^ 0xCE4B).to_s(16)
    end
def password_hash(pwd)
      hsh = 0
      pwd.reverse.each_char { |c|
        hsh = hsh ^ c.ord
        hsh = hsh << 1
        hsh -= 0x7fff if hsh > 0x7fff
      }

      (hsh ^ pwd.length ^ 0xCE4B).to_s(16)
    end
Calculate password hash from string for use in 'password' fields.
 https://www.openoffice.org/sc/excelfileformat.pdf