1 Star 0 Fork 0

墙外行人/gooxml

Create your Gitee Account
Explore and code with more than 14 million developers,Free private repositories !:)
Sign up
文件
Clone or Download
password.go 907 Bytes
Copy Edit Raw Blame History
Carmel authored 2019-12-15 20:35 +08:00 . change dependency
// Copyright 2017 Baliance. All rights reserved.
//
// Use of this source code is governed by the terms of the Affero GNU General
// Public License version 3.0 as published by the Free Software Foundation and
// appearing in the file LICENSE included in the packaging of this file. A
// commercial license can be purchased by contacting sales@baliance.com.
package spreadsheet
import (
"fmt"
)
// PasswordHash returns the password hash for a workbook using the modified
// spreadsheetML password hash that is compatible with Excel.
func PasswordHash(s string) string {
hash := uint16(0)
if len(s) > 0 {
for i := len(s) - 1; i >= 0; i-- {
c := s[i]
hash = ((hash >> 14) & 0x01) | ((hash << 1) & 0x7fff)
hash ^= uint16(c)
}
hash = ((hash >> 14) & 0x01) | ((hash << 1) & 0x7fff)
hash ^= uint16(len(s))
hash ^= (0x8000 | ('N' << 8) | 'K')
}
return fmt.Sprintf("%04X", uint64(hash))
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/qwxren/gooxml.git
git@gitee.com:qwxren/gooxml.git
qwxren
gooxml
gooxml
v1.0.17-alpha

Search