MCPcopy
hub / github.com/qax-os/excelize / Decrypt

Function Decrypt

crypt.go:143–160  ·  view source on GitHub ↗

Decrypt API decrypts the CFB file format with ECMA-376 agile encryption and standard encryption. Support cryptographic algorithm: MD4, MD5, RIPEMD-160, SHA1, SHA256, SHA384 and SHA512 currently.

(raw []byte, opts *Options)

Source from the content-addressed store, hash-verified

141// standard encryption. Support cryptographic algorithm: MD4, MD5, RIPEMD-160,
142// SHA1, SHA256, SHA384 and SHA512 currently.
143func Decrypt(raw []byte, opts *Options) (packageBuf []byte, err error) {
144 doc, err := mscfb.New(bytes.NewReader(raw))
145 if err != nil {
146 return
147 }
148 var encryptionInfoBuf, encryptedPackageBuf []byte
149 if encryptionInfoBuf, encryptedPackageBuf, err = extractPart(doc); err != nil {
150 return
151 }
152 mechanism, err := encryptionMechanism(encryptionInfoBuf)
153 if err != nil || mechanism == "extensible" {
154 return
155 }
156 if mechanism == "agile" {
157 return agileDecrypt(encryptionInfoBuf, encryptedPackageBuf, opts)
158 }
159 return standardDecrypt(encryptionInfoBuf, encryptedPackageBuf, opts)
160}
161
162// Encrypt API encrypt data with the password.
163func Encrypt(raw []byte, opts *Options) ([]byte, error) {

Callers 2

TestEncryptFunction · 0.85
OpenReaderFunction · 0.85

Calls 4

extractPartFunction · 0.85
encryptionMechanismFunction · 0.85
agileDecryptFunction · 0.85
standardDecryptFunction · 0.85

Tested by 1

TestEncryptFunction · 0.68