Esempio n. 1
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("")
Esempio n. 2
0
 def rc2_calc_encrypt(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(),self.chkrc2_key_ishex.isChecked())
         buff_iv = Util.getBuff(self.txtrc2_iv.text(), self.chkrc2_iv_ishex.isChecked())
         mode = ARC2.MODE_CBC
         if self.cmbrc2_mode.currentIndex()==1:
             res=CryptoUtil.rc2_ebc_encrypt(buff_key,inputdata)
         else:
             res = CryptoUtil.rc2_cbc_encrypt(buff_key,buff_iv,inputdata)
         self.txtrc2_output.setPlainText(Util.b2hex(res))
     except Exception as ex:
         self.appendLog(str(ex))
         self.txtrc2_output.setPlainText("")