+ @staticmethod
+ def _join_passwords(passwd_byte, passwd_str):
+ """
+ Modifies passwd_byte with the xor of passwd_str. Used for adding salt, join passwords, etc
+ :param passwd_byte: original password in bytes, 32 byte length
+ :param passwd_str: string salt to be added
+ :return: modified password in bytes
+ """
+ if not passwd_str:
+ return passwd_byte
+ secret_key = bytearray(passwd_byte)
+ for i, b in enumerate(passwd_str.encode()):
+ secret_key[i % 32] ^= b
+ return bytes(secret_key)
+
+ def set_secret_key(self, secret_key):
+ """
+ Set internal secret key used for encryption
+ :param secret_key: byte array length 32 with the secret_key
+ :return: None
+ """
+ assert (len(secret_key) == 32)
+ self.secret_key = self._join_passwords(secret_key, self.master_password)
+
+ def encrypt(self, value, schema_version=None, salt=None):