コード例 #1
0
 def varint_calc_encode(self):
     inputdata=self.txtvarint_input.toPlainText()
     try:
         if "0x" in inputdata:
             inputdata=inputdata.replace("0x","")
             inputNum=int(inputdata,16)
             res = Util.varint_encode(inputNum)
             self.txtvarint_output.setPlainText(Util.b2hexSpace(res))
             return
         else:
             inputNum = int(inputdata, 10)
             res = Util.varint_encode(inputNum)
             self.txtvarint_output.setPlainText(Util.b2hexSpace(res))
     except Exception as ex:
         self.appendLog(str(ex))
         self.txtvarint_output.setPlainText("")
コード例 #2
0
 def hmac_calc(self):
     buff = Util.getBuff(self.txthmac_input.toPlainText(),self.chkhmac_ishex.isChecked())
     if len(buff) <= 0:
         self.appendLog("hmac input未输入正确数据")
         return
     buff_key=Util.getBuff(self.txthmac_key.text(),self.chkhmac_key_ishex.isChecked())
     if self.chkhmac_key_ishex.isChecked():
         self.txthmac_key.setText(Util.b2hexSpace(buff_key))
     cmbidx = self.cmbhmac.currentIndex()
     if cmbidx == 1:
         m = hashlib.sha1
     elif cmbidx == 2:
         m = hashlib.sha224
     elif cmbidx == 3:
         m = hashlib.sha256
     elif cmbidx == 4:
         m = hashlib.sha512
     else:
         m = hashlib.md5
     try:
         h = hmac.new(buff_key,buff,digestmod=m)
         self.txthmac_output.setPlainText(h.hexdigest())
     except Exception as ex:
         self.appendLog(str(ex))
         self.txthmac_output.setPlainText("")
コード例 #3
0
 def binformat_calc_bytes(self):
     inputdata=self.txtbinformat_input.toPlainText()
     try:
         res = Util.str2hex(inputdata)
         self.txtbinformat_output.setPlainText(Util.b2hexSpace(res))
         cnt = len(res)
         self.lbbinformat_cnt.setText("<span style=' color:#ff0000;'>[{}]</span>".format(cnt))
     except Exception as ex:
         self.appendLog("转换异常:" + str(ex))
         self.txtbinformat_output.setPlainText("")