我们从Python开源项目中,提取了以下8个代码示例,用于说明如何使用utils.sha256()。
def _sendSMBMessage_SMB2(self, smb_message): if smb_message.mid == 0: smb_message.mid = self._getNextMID_SMB2() if smb_message.command != SMB2_COM_NEGOTIATE and smb_message.command != SMB2_COM_ECHO: smb_message.session_id = self.session_id if self.is_signing_active: smb_message.flags |= SMB2_FLAGS_SIGNED raw_data = smb_message.encode() smb_message.signature = hmac.new(self.signing_session_key, raw_data, sha256).digest()[:16] smb_message.raw_data = smb_message.encode() self.log.debug('MID is %d. Signature is %s. Total raw message is %d bytes', smb_message.mid, binascii.hexlify(smb_message.signature), len(smb_message.raw_data)) else: smb_message.raw_data = smb_message.encode() self.sendNMBMessage(smb_message.raw_data)