예제 #1
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("")
예제 #2
0
 def rc2_calc_decrypt(self):
     inputdata = Util.getBuff(self.txtrc2_input.toPlainText(), self.chkrc2_ishex.isChecked())
     if len(inputdata) <= 0:
         self.appendLog("rc2 input为空")
         return
     try:
         buff_key = Util.getBuff(self.txtrc2_key.text(), True)
         buff_iv = Util.getBuff(self.txtrc2_iv.text(), self.chkrc2_iv_ishex.isChecked())
         if self.cmbrc2_mode.currentIndex() == 1:
             res = CryptoUtil.rc2_ebc_decrypt(buff_key, inputdata)
         else:
             res = CryptoUtil.rc2_cbc_decrypt(buff_key, buff_iv, inputdata)
         self.txtrc2_output.setPlainText(res)
     except Exception as ex:
         self.appendLog(str(ex))
         self.txtrc2_output.setPlainText("")
예제 #3
0
 def zlib_calc_unzlib(self):
     inputdata =Util.getBuff(self.txtzlib_input.toPlainText(),True)
     try:
         res = Util.zlib_decompress(inputdata)
         self.txtzlib_output.setPlainText(res)
     except Exception as ex:
         self.appendLog(str(ex))
         self.txtzlib_output.setPlainText("")
예제 #4
0
 def zlib_calc(self):
     inputdata=Util.getBuff(self.txtzlib_input.toPlainText(),self.chkzlib_ishex.isChecked())
     try:
         res=Util.zlib_compress(inputdata)
         self.txtzlib_output.setPlainText(res)
     except Exception as ex:
         self.appendLog(str(ex))
         self.txtzlib_output.setPlainText("")
예제 #5
0
 def adler32_calc(self):
     buff = Util.getBuff(self.txtadler32_input.toPlainText(),self.chkadler32_ishex.isChecked())
     if len(buff) <= 0:
         self.appendLog("adler32 input未输入正确数据")
         return
     try:
         res = zlib.adler32(buff)
         self.txtadler32_output.setPlainText(str(res))
     except Exception as ex:
         self.appendLog(str(ex))
         self.txtadler32_output.setPlainText("")
예제 #6
0
 def aes_calc_decrypt(self):
     buff = Util.getBuff(self.txtaes_input.toPlainText(), True)
     if len(buff) <= 0:
         self.appendLog("aes input未输入正确数据")
         return
     buffkey = Util.getBuff(self.txtaes_key.text(), self.chkaes_key_ishex.isChecked())
     buffiv = Util.getBuff(self.txtaes_iv.text(), self.chkaes_iv_ishex.isChecked())
     try:
         if self.cmbaes_mode.currentIndex() == Enums.AES_MODE.CBC.value:
             res = CryptoUtil.aes_cbc_decrypt(buffkey, buffiv, buff)
             self.txtaes_output.setPlainText(Util.b2hex(res))
         elif self.cmbaes_mode.currentIndex() == Enums.AES_MODE.ECB.value:
             res = CryptoUtil.aes_ecb_decrypt(buffkey, buff)
             self.txtaes_output.setPlainText(Util.b2hex(res))
         elif self.cmbaes_mode.currentIndex() == Enums.AES_MODE.GCM.value:
             buff_nonce = Util.getBuff(self.txtaes_nonce.text(), self.chkaes_nonce_ishex.isChecked())
             bufftag = Util.getBuff(self.txtaes_tag.text(), self.chkaes_tag_ishex.isChecked())
             res = CryptoUtil.aes_gcm_decrypt(buffkey, buffiv, buff_nonce, buff, bufftag)
             self.txtaes_output.setPlainText(Util.b2hex(res))
     except Exception as ex:
         self.appendLog(str(ex))
         self.txtaes_output.setPlainText("")
예제 #7
0
 def md5_calc(self):
     buff =Util.getBuff(self.txtmd5_input.toPlainText(),self.chkmd5_ishex.isChecked())
     if len(buff) <= 0:
         self.appendLog("md5 input未输入正确数据")
         return
     try:
         m= hashlib.md5()
         m.update(buff)
         res = m.hexdigest()
         self.txtmd5_output.setPlainText(res)
     except Exception as ex:
         self.appendLog(str(ex))
         self.txtmd5_output.setPlainText("")
예제 #8
0
 def sha_calc(self):
     buff =Util.getBuff(self.txtsha_input.toPlainText(),self.chksha_ishex.isChecked())
     if len(buff) <= 0:
         self.appendLog("sha input未输入正确数据")
         return
     cmbidx=self.cmbsha.currentIndex()
     if cmbidx==1:
         m = hashlib.sha1()
     elif cmbidx==2:
         m = hashlib.sha224()
     elif cmbidx==3:
         m = hashlib.sha512()
     else:
         m = hashlib.sha256()
     try:
         m.update(buff)
         res = m.hexdigest()
         self.txtsha_output.setPlainText(res)
     except Exception as ex:
         self.appendLog(str(ex))
         self.txtsha_output.setPlainText("")