def data_encryption(connection, KeyId, Versus=None, Data=None, WorkingKey=''): """ Keyboard and Security, Data encryption (0x40, 0x03). :Parameters: -*connection* (PupySPOT): Object managing spot connection. - *KeyId* (integer): Slot ID of Master Key. - *Versus* (Enums.Versus): Operation required. - *Data* (bytes array): Data block on which the operation is performed. - *WorkingKey* (bytes array): Working Key value encrypted with Master Key. :Returns: Ack-Code indicating successful of the operation. """ Protocol.send_data_encryption(connection, keyid = KeyId, versus = Versus, data = Data, mode = 0x00 if WorkingKey == '' else 0x01, working_key = WorkingKey) ack = Protocol.recv_data_encryption(connection, timeout = 120) if ack['ack_code'] != 0x00: ack['Data'] = None return ack['ack_code'], ack['Data']