예제 #1
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("")
예제 #2
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("")
예제 #3
0
 def rsa_decrypt(self):
     res=CryptoUtil.rsa_decrypt(self.txtrsa_prikey.toPlainText(),self.txtrsa_input.toPlainText())
     self.txtrsa_output.setPlainText(res.decode("utf-8"))
예제 #4
0
 def rsa_gen(self):
     pubkey,prikey=CryptoUtil.generateKey()
     self.txtrsa_pubkey.setPlainText(pubkey.decode("utf-8"))
     self.txtrsa_prikey.setPlainText(prikey.decode("utf-8"))