1from __future__ import absolute_import
2import hashlib
3
4from openpyxl.descriptors import (Bool, Integer, String)
5from openpyxl.descriptors.excel import Base64Binary
6from openpyxl.descriptors.serialisable import Serialisable
7
8from openpyxl.worksheet.protection import (
9    hash_password,
10    _Protected
11)
12
13
14class ChartsheetProtection(Serialisable, _Protected):
15    tagname = "sheetProtection"
16
17    algorithmName = String(allow_none=True)
18    hashValue = Base64Binary(allow_none=True)
19    saltValue = Base64Binary(allow_none=True)
20    spinCount = Integer(allow_none=True)
21    content = Bool(allow_none=True)
22    objects = Bool(allow_none=True)
23
24    __attrs__ = ("content", "objects", "password", "hashValue", "spinCount", "saltValue", "algorithmName")
25
26    def __init__(self,
27                 content=None,
28                 objects=None,
29                 hashValue=None,
30                 spinCount=None,
31                 saltValue=None,
32                 algorithmName=None,
33                 password=None,
34                 ):
35        self.content = content
36        self.objects = objects
37        self.hashValue = hashValue
38        self.spinCount = spinCount
39        self.saltValue = saltValue
40        self.algorithmName = algorithmName
41        if password is not None:
42            self.password = password
43