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)
| 141 | // standard encryption. Support cryptographic algorithm: MD4, MD5, RIPEMD-160, |
| 142 | // SHA1, SHA256, SHA384 and SHA512 currently. |
| 143 | func 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. |
| 163 | func Encrypt(raw []byte, opts *Options) ([]byte, error) { |