{"record":{"id":"068fe3cad1a3d17d","repo":"qax-os/excelize","slug":"errunsupportedencryptmechanism","errorCode":"ErrUnsupportedEncryptMechanism","errorMessage":"unsupported encryption mechanism","messagePattern":"unsupported encryption mechanism","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"errors.go","lineNumber":194,"sourceCode":"\tErrTransparency = errors.New(\"transparency value must be an integer from 0 to 100\")\n\t// ErrUnknownEncryptMechanism defined the error message on unsupported\n\t// encryption mechanism.\n\tErrUnknownEncryptMechanism = errors.New(\"unknown encryption mechanism\")\n\t// ErrUnprotectSheet defined the error message on worksheet has set no\n\t// protection.\n\tErrUnprotectSheet = errors.New(\"worksheet has set no protect\")\n\t// ErrUnprotectSheetPassword defined the error message on remove sheet\n\t// protection with password verification failed.\n\tErrUnprotectSheetPassword = errors.New(\"worksheet protect password not match\")\n\t// ErrUnprotectWorkbook defined the error message on workbook has set no\n\t// protection.\n\tErrUnprotectWorkbook = errors.New(\"workbook has set no protect\")\n\t// ErrUnprotectWorkbookPassword defined the error message on remove workbook\n\t// protection with password verification failed.\n\tErrUnprotectWorkbookPassword = errors.New(\"workbook protect password not match\")\n\t// ErrUnsupportedEncryptMechanism defined the error message on unsupported\n\t// encryption mechanism.\n\tErrUnsupportedEncryptMechanism = errors.New(\"unsupported encryption mechanism\")\n\t// ErrUnsupportedHashAlgorithm defined the error message on unsupported\n\t// hash algorithm.\n\tErrUnsupportedHashAlgorithm = errors.New(\"unsupported hash algorithm\")\n\t// ErrUnsupportedNumberFormat defined the error message on unsupported\n\t// number format expression.\n\tErrUnsupportedNumberFormat = errors.New(\"unsupported number format token\")\n\t// ErrUnsupportedPivotTableShowValuesAsType defined the error message on\n\t// receiving the unsupported pivot table \"show values as\" type.\n\tErrUnsupportedPivotTableShowValuesAsType = errors.New(\"unsupported pivot table show values as type\")\n\t// ErrWorkbookFileFormat defined the error message on receive an\n\t// unsupported workbook file format.\n\tErrWorkbookFileFormat = errors.New(\"unsupported workbook file format\")\n\t// ErrWorkbookPassword defined the error message on receiving the incorrect\n\t// workbook password.\n\tErrWorkbookPassword = errors.New(\"the supplied open workbook password is not correct\")\n)\n\n// ErrSheetNotExist defined an error of sheet that does not exist.","sourceCodeStart":176,"sourceCodeEnd":212,"githubUrl":"https://github.com/qax-os/excelize/blob/f2483381fbfbe432a6baa98d48a1c277183f3285/errors.go#L176-L212","documentation":"ErrUnsupportedEncryptMechanism indicates that the workbook's EncryptionInfo declares an encryption mechanism the library cannot handle. encryptionMechanism parses the header; known mechanisms are consumed, otherwise the function returns this error (crypt.go:229 default branch).","triggerScenarios":"Decrypt/OpenReader on a file whose EncryptionInfo header bytes name an unsupported mechanism; tests set raw[2050]=3 (e.g. AES-ish/unknown specifier) to trigger it; also the fall-through after mechanism=\"extensible\".","commonSituations":"Files encrypted with non-standard or third-party encryption schemes (e.g. agile encryption variants excelize does not support); files encrypted by other tools.","solutions":["Re-save the workbook with standard Excel encryption supported by excelize","Decrypt the file with the tool that produced it before opening with excelize","Upgrade excelize, which may add support for more mechanisms"],"exampleFix":"// before\nf, err := OpenFile(\"thirdparty-encrypted.xlsx\") // unsupported mechanism\n// after\ncmd := exec.Command(\"tool\", \"--decrypt\", \"thirdparty-encrypted.xlsx\") // decrypt externally first\nf, err := OpenFile(\"decrypted.xlsx\")","handlingStrategy":"fallback","validationCode":"// check the OLE EncryptionInfo stream header before decrypting; only proceed for mechanisms excelize documents as supported","typeGuard":"func isKnownMechanism(header []byte) bool {\n\treturn len(header) >= 4 // + whitelist known 4-byte mechanism specifiers\n}","tryCatchPattern":"f, err := excelize.OpenReader(r)\nif errors.Is(err, excelize.ErrUnsupportedEncryptMechanism) {\n\treturn decryptExternallyThenOpen(r)\n}\nreturn err","preventionTips":["Prefer standard Excel (agile/standard) encryption when producing files","Decrypt with the original tool before handing to excelize","Keep excelize updated for broader mechanism support"],"tags":["go","excelize","encryption","unsupported"],"backgroundTag":"unsupported-encryption-mechanism","analyzedSha":"f2483381fbfbe432a6baa98d48a1c277183f3285","analyzedAt":"2026-09-02T01:26:19.299Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}