def engineering(): dir_path = os.path.dirname(os.path.realpath(__file__)) tree = ET2.parse(dir_path + "\\tools.xml") sub = "engineering" result = tree.xpath('/tools/tool[subject = "' + sub + '"]') tools = [] for t in result: title = t[0].text position = t[1].text href = t[2].text change = t[3].text category = t[4].text datet = t[7].text subject = t[8].text if t[5].text == "True": learning = True else: learning = False if t[6].text == "True": teaching = True else: teaching = False newTool = Tool(title, position, href, change, category, learning, teaching, datet, subject) tools.append(newTool) return render_template('listby.html', tools=tools)
def engineeringrdf(): tools = [] url = dir_path + "/mainr.rdf" uri = pathlib.Path(url).as_uri() g = Graph() g.parse(url, format="xml") for i in range(201): if (i == 0): s = URIRef(uri + '#tools/tool/') if (i != 0 and i != 1): s = URIRef(uri + '#tools/tool_' + str(i) + '/') subject = findInGraph(g=g, sub=s + "subject") if (str(subject) == "engineering"): title = findInGraph(g=g, sub=s + "title") position = findInGraph(g=g, sub=s + "position") href = findInGraph(g=g, sub=s + "href") change = findInGraph(g=g, sub=s + "change") category = findInGraph(g=g, sub=s + "category") datet = findInGraph(g=g, sub=s + "datet") subject = findInGraph(g=g, sub=s + "subject") learning = findInGraph(g=g, sub=s + "learning") teaching = findInGraph(g=g, sub=s + "teaching") newTool = Tool(title, position, href, change, category, learning, teaching, datet, subject) tools.append(newTool) return render_template('listby.html', tools=tools)
def about(): dir_path = os.path.dirname(os.path.realpath(__file__)) parser = ET2.XMLParser(remove_blank_text=True) tree = ET2.parse(dir_path + "\\tools.xml", parser) name = request.form.get("title", "") result = tree.xpath('/tools/tool[title = "' + name + '"]') tool = ET2.tostring(result[0], pretty_print=True) root = ET.fromstring(tool) title = root[0].text position = root[1].text href = root[2].text change = root[3].text category = root[4].text datet = root[7].text subject = root[8].text if root[5].text == "True": learning = True else: learning = False if root[6].text == "True": teaching = True else: teaching = False newTool = Tool(title, position, href, change, category, learning, teaching, datet, subject) return render_template('about.html', tool=newTool)
def __init__(self, scene, camera): VisBackend.__init__(self) #self.name_counter = 0 #self.matrix_counter = 0 self.names = {} self.clip_constants = [ GL_CLIP_PLANE0, GL_CLIP_PLANE1, GL_CLIP_PLANE2, GL_CLIP_PLANE3, GL_CLIP_PLANE4, GL_CLIP_PLANE5 ] self.tool = Tool()
def top10rdf(): tools = [] url = dir_path + "/mainr.rdf" uri = pathlib.Path(url).as_uri() g = Graph() g.parse(url, format="xml") """ s = URIRef('file:///C://Users/Stefan/Desktop/aas.rdf#tools/tool_2/title') title = "" for person in g.objects(subject=s): print(person) print("----------------") title=person print(title) """ for i in range(201): if (i == 0): s = URIRef(uri + '#tools/tool/') if (i != 0 and i != 1): s = URIRef(uri + '#tools/tool_' + str(i) + '/') position = findInGraph(g=g, sub=s + "position") if (int(position) <= 10): title = findInGraph(g=g, sub=s + "title") position = findInGraph(g=g, sub=s + "position") href = findInGraph(g=g, sub=s + "href") change = findInGraph(g=g, sub=s + "change") category = findInGraph(g=g, sub=s + "category") datet = findInGraph(g=g, sub=s + "datet") subject = findInGraph(g=g, sub=s + "subject") learning = findInGraph(g=g, sub=s + "learning") teaching = findInGraph(g=g, sub=s + "teaching") newTool = Tool(title, position, href, change, category, learning, teaching, datet, subject) tools.append(newTool) """ for i in range(2,11): s = URIRef('file:///C://Users/Stefan/Desktop/aas.rdf#tools/tool_'+str(i)+'/') title = findInGraph(g=g,sub=s + "title") position = findInGraph(g=g,sub=s + "position") href = findInGraph(g=g,sub=s + "href") change = findInGraph(g=g,sub=s + "change") category = findInGraph(g=g,sub=s + "category") datet = findInGraph(g=g,sub=s + "datet") subject = findInGraph(g=g,sub=s + "subject") learning = findInGraph(g=g,sub=s + "learning") teaching = findInGraph(g=g,sub=s + "teaching") newTool = Tool(title, position, href, change, category, learning, teaching, datet, subject) tools.append(newTool) """ return render_template('listby.html', tools=tools)
def parse_single_page(self, url): """ 解析单个文章的内容,只取文章主体部分,作为主题生成的原材料 """ content = self.download(url) if content == "": return pattern = re.compile('<div id="cnblogs_post_body".*?>(.*?)</div>', re.S) match = pattern.search(content) if match: body = match.group(1) t = Tool() body = t.replace(body) self.dump_page_content(url, body) else: print("Parse page error")
def getcategory(): if request.method == 'POST': categ = request.form.get("category", "") print(categ) dir_path = os.path.dirname(os.path.realpath(__file__)) tree = ET2.parse(dir_path + "\\tools.xml") result = tree.xpath('/tools/tool[category = "' + categ + '"]') tools = [] for t in result: title = t[0].text position = t[1].text href = t[2].text change = t[3].text category = t[4].text datet = t[7].text subject = t[8].text if t[5].text == "True": learning = True else: learning = False if t[6].text == "True": teaching = True else: teaching = False newTool = Tool(title, position, href, change, category, learning, teaching, datet, subject) tools.append(newTool) return render_template('listby.html', tools=tools) dir_path = os.path.dirname(os.path.realpath(__file__)) tree = ET.parse(dir_path + "\\tools.xml") root = tree.getroot() categories = [] for tool in root.findall('./tool'): category = tool[4].text if category not in categories: categories.append(category) sorted_categories = sorted(categories, key=str.casefold) return render_template("catform.html", categories=sorted_categories)
def days(): if request.method == 'POST': days = request.form.get("days", "") todays = date.today().strftime("%d/%m/%Y") todaysdate = datetime.datetime.strptime(todays, "%d/%m/%Y") daysformated = datetime.timedelta(int(days)) difference = todaysdate - daysformated differencestr = difference.strftime("%Y/%m/%d") differencestr = differencestr.replace("/", "") print(differencestr) #/tools/tool[number(translate(date,'/','')) > 03122020] dir_path = os.path.dirname(os.path.realpath(__file__)) tree = ET2.parse(dir_path + "\\tools.xml") result = tree.xpath("/tools/tool[number(translate(date,'/','')) >= " + differencestr + "]") tools = [] for t in result: title = t[0].text position = t[1].text href = t[2].text change = t[3].text category = t[4].text datet = t[7].text subject = t[8].text if t[5].text == "True": learning = True else: learning = False if t[6].text == "True": teaching = True else: teaching = False newTool = Tool(title, position, href, change, category, learning, teaching, datet, subject) tools.append(newTool) return render_template('listby.html', tools=tools) return render_template('days.html')
def index(): dir_path = os.path.dirname(os.path.realpath(__file__)) #dom = ET2.parse(dir_path + "\\tools.xml") #xslt = ET2.parse(dir_path + "\\template.xsl") #transform = ET2.XSLT(xslt) #newdom = transform(dom) #xml_file = open(dir_path + "\\templates\\file.html", "w") #xml_file.write(str(ET2.tostring(newdom))) #xml_file.close() #return render_template('file.html') tree = ET.parse(dir_path + "\\tools.xml") root = tree.getroot() tools = [] categories = [] for tool in root.findall('./tool'): title = tool[0].text position = tool[1].text href = tool[2].text change = tool[3].text category = tool[4].text datet = tool[7].text subject = tool[8].text if tool[5].text == "True": learning = True else: learning = False if tool[6].text == "True": teaching = True else: teaching = False newTool = Tool(title, position, href, change, category, learning, teaching, datet, subject) tools.append(newTool) if category not in categories: categories.append(category) sorted_categories = sorted(categories, key=str.casefold) return render_template('index.html', tools=tools, categories=sorted_categories)
def __init__(self): self.tool = Tool() self.id3 = Id3Util()
def train(dataset='A'): # 训练数据集路径 img_root_dir = './data/ShanghaiTech/part_' + dataset + '_final/train_data/images/' gt_root_dir = './data/ShanghaiTech/part_' + dataset + '_final/train_data/ground_truth/' # 测试数据集路径 test_img_dir = './data/ShanghaiTech/part_' + dataset + '_final/test_data/images/' test_gt_dir = './data/ShanghaiTech/part_' + dataset + '_final/test_data/ground_truth/' img_file_list = os.listdir(img_root_dir) # gt_file_list = os.listdir(gt_root_dir) test_img_list = os.listdir(test_img_dir) # test_gt_list = os.listdir(test_gt_dir) model_name = 'mcdcnn_SHTech_' + dataset cfg = Config(model_name) cfg.lr = 1e-4 tool = Tool() model = Model() network = model.mcdcnn() INPUT, GT_DMP, GT_CNT, EST_DMP, EST_CNT = network['INPUT'], network['GT_DMP'], network['GT_CNT'], \ network['EST_DMP'], network['EST_CNT'] loss = model.losses(GT_DMP, GT_CNT, EST_DMP, EST_CNT) # 学习率衰变设置 global_step = tf.Variable(0, trainable=False) lr = tf.train.exponential_decay(cfg.lr, global_step=global_step, decay_steps=cfg.lr_decay_step, decay_rate=cfg.lr_decay_rate, staircase=True) # 优化器 optimizer = tf.train.AdamOptimizer(lr).minimize(loss, global_step) # 模型保存设置 saver = tf.train.Saver(max_to_keep=cfg.max_ckpt_keep) ckpt = tf.train.get_checkpoint_state(cfg.ckpt_router) # 创建会话 with tf.Session() as sess: sess.run(tf.global_variables_initializer()) # 加载模型 if ckpt and ckpt.model_checkpoint_path: print('load model') saver.restore(sess, ckpt.model_checkpoint_path) # 训练日志文件路径设置 if not os.path.exists(cfg.log_router): os.makedirs(cfg.log_router) log = open(cfg.log_router + 'train' + r'.logs', mode='a+', encoding='utf-8') # 迭代训练 num = len(img_file_list) # 开始训练 for i in tqdm(range(cfg.iter_num)): # 随机打乱 np.random.shuffle(img_file_list) for j in tqdm(range(num)): img_path = img_root_dir + img_file_list[j] gt_path = gt_root_dir + 'GT_' + img_file_list[j].split(r'.')[0] img, dmp, cnt = tool.read_train_data(img_path, gt_path, use_knn=True) feed_dict = {INPUT: img, GT_DMP: dmp, GT_CNT: cnt} _, est_dmp, est_cnt, train_loss = sess.run( [optimizer, EST_DMP, EST_CNT, loss], feed_dict=feed_dict) format_time = str( time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())) format_str = 'step %d, loss = %.3f, gt = %d, inference = %.3f' log_line = format_time, img_file_list[j], format_str % ( (i * num + j), train_loss, cnt, est_cnt) print(log_line) log.writelines(str(log_line) + '\n') sess.run(lr, feed_dict={global_step: i * num + j}) if i % cfg.snap == 0: # 保存模型 saver.save(sess, cfg.ckpt_router + '/v1', global_step=i) # 进行测试 print('testing', i, '> > > > > > > > > > > > > > > > > > >') total_mae = 0.0 total_mse = 0.0 num = len(test_img_list) log_line = '' for k in tqdm(range(num - 2, num)): img_path = test_img_dir + test_img_list[k] gt_path = test_gt_dir + 'GT_' + test_img_list[k].split( r'.')[0] img, dmp, cnt = tool.read_test_data(img_path, gt_path, use_knn=True) feed_dict = {INPUT: img, GT_DMP: dmp, GT_CNT: cnt} est_cnt, test_loss = sess.run([EST_CNT, loss], feed_dict=feed_dict) format_time = str( time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())) format_str = 'step %d, joint loss = %.3f, gt = %d, inference = %.3f' line = str(format_time + ' ' + test_img_list[k] + ' ' + format_str % (k, test_loss, cnt, est_cnt) + '\n') log_line += line total_mae += tool.mae_metrix(cnt, est_cnt) total_mse += tool.mse_metrix(cnt, est_cnt) print(line) avg_mae = total_mae / num avg_mse = pow(total_mse / num, 0.5) result = str('_MAE_%.5f_MSE_%.5f' % (avg_mae, avg_mse)) test_log = open(cfg.log_router + 'test_' + str(i) + result + r'.logs', mode='a+', encoding='utf-8') test_log.writelines(result + '\n') test_log.writelines(str(log_line) + '\n') test_log.close() log.close()
# -*- coding: utf-8 -*- """ Created on Thu Oct 25 14:41:32 2018 @author: WellenWoo """ from __future__ import print_function import torch import torch.nn as nn import torch.optim as optim import torchvision.models as models import copy import time import re from tools import Tool tl = Tool() class ContentLoss(nn.Module): """内容损失""" def __init__(self, target, weight): super(ContentLoss, self).__init__() # 我们会从所使用的树中“分离”目标内容 self.target = target.detach() * weight # 动态地计算梯度: 它是个状态值, 不是变量. # 否则评价指标的前向方法会抛出错误. self.weight = weight self.criterion = nn.MSELoss() def forward(self, inputs): self.loss = self.criterion(inputs * self.weight, self.target)
# coding: utf-8 from flask import Flask, render_template, send_from_directory from os.path import isdir, isfile from os import listdir from tools import Tool from fuzzywuzzy import process app = Flask(__name__) tool = Tool() # Initilize search engine fuzzy_choices = [] fuzzy_choices_lower = [] ko = 0 match_search = tool.get('use_match') music_db = tool.get('music_database') if isfile(music_db): with open(tool.get('music_database')) as f: for line in f: try: entry = line.strip().decode('utf-8') fuzzy_choices.append(entry) # put computed lower string in cache if match_search: fuzzy_choices_lower.append(entry.lower()) except Exception as decodeError: ko += 0 if ko: tool.debug(ko, 'files could not be add to the seach engine') search_limit = tool.get('search_limit')
from tkinter import * from tkinter.ttk import * from tkinter.colorchooser import askcolor import io import datetime import time from tkinter import filedialog from PIL import ImageTk, Image from tkinter.filedialog import asksaveasfile from math import sqrt # defined from canvas_image import CreateCanvasObject from tools import Tool from about import * pen = Tool('Pen', 'black', 2) brush = Tool('Brush', 'green', 5) eraser = Tool('Eraser', 'white', 5) shapes = Tool('Shape', 'black', 2) tools = [pen, brush, eraser, shapes] global selectedindex selectedindex = 0 lastx, lasty = None, None topx, topy, botx, boty = 0, 0, 0, 0 global shape_id global count
import time import serial from tools import Tool TEMPERATURE_THRESHOLD = 28.0 t = Tool('feverfinder', 'Shivaal') ser = serial.Serial('/dev/cu.usbmodem1421', 9600) alarm_sent = False count = 0 while True: line = ser.readline().strip() count += 1 print line if count > 5: t.addTemperature(float(line), int(time.time() * 1000)) if not alarm_sent and float(line) > TEMPERATURE_THRESHOLD: print "ALERT! High temperature in bed 14." t.send_sms() alarm_sent = True
import re mongo = CbyMongo() # weixin = mongo.getTable('weixin') # tool = Tool() # totalPage = tool.getTotalPage() # for index in range(totalPage): # newUrl = '/wechat/search-catid-1-type-price_one-page-' + str( index + 1) + '.html' # print(newUrl) # newTool = Tool(url = newUrl) # newContent = newTool.getContent() # print(newContent) # weixin.insert_many(newContent) starter = Tool() html = starter.loadHtml() category = starter.getCategory(html) for cat in category: catName = re.findall(r'/([a-zA-Z]*)/search.html', cat)[0] if catName == 'zanzhu': print(u'--------进入 %s 模块-----------' % catName) mongoTool = mongo.getTable(catName) catLoader = Tool() newHtml = catLoader.loadHtml(url=cat) getTotalPage = catLoader.getTotalPage(newHtml) allUrl = catLoader.getAllUrl(newHtml) for index in range(getTotalPage): page = (index + 1) print(u'--------爬取 %s 模块,第 %d 页-----------' % (catName, page))
def choose(arg): attack = str(accueil(arg)) if attack == "1": print("\n\t\t\t ***** Wiener Attack *****") args = input( "\n\t\t[*] Arguments ([-h] -n modulus -e exponent):\n\n\t\t\t" ).split() parser = argparse.ArgumentParser( description='This program allows to carry out a Wiener Attack') parser.add_argument('-n', dest='n', type=int, help='RSA public key modulus', required=True) parser.add_argument('-e', dest='e', type=int, help='RSA public key exponent', required=True) params = parser.parse_args(args) attack_object = Attack(params) attack_object.wiener() elif attack == "2": print("\n\t\t\t ***** Hastad Attack *****") try: args = input( "\n\t\t[*] Arguments ([-h] -n0 modulus_key0 -n1 modulus_key1 -n2 modulus_key2 -e public_exponent -c0 cipher1 -c1 cipher2 -c2 cipher3):\n\n\t\t\t" ).split() except: print("\n\t\t\t[-] Argument Error: Please verify your inputs\n") exit() parser = argparse.ArgumentParser( description='This program allows to carry out an Hastad Attack') parser.add_argument( '-n0', dest='n0', type=int, help='Modulus of the first RSA pulic key (decimal)', required=True) parser.add_argument( '-n1', dest='n1', type=int, help='Modulus of the second RSA pulic key (decimal)', required=True) parser.add_argument( '-n2', dest='n2', type=int, help='Modulus of the third RSA pulic key (decimal)', required=True) parser.add_argument('-e', dest='e', type=int, help='Common public exponent (decimal)', required=True) parser.add_argument('-c0', dest='c0', type=int, help='first ciphertext (decimal)', required=True) parser.add_argument('-c1', dest='c1', type=int, help='second ciphertext (decimal)', required=True) parser.add_argument('-c2', dest='c2', type=int, help='third ciphertext (decimal)', required=True) params = parser.parse_args(args) attack_object = Attack(params) attack_object.hastad() elif attack == "3": print("\n\t\t\t ***** Fermat Attack *****") try: args = input( "\n\t\t[*] Arguments ([-h] -n modulus -e exponent):\n\n\t\t\t" ).split() except: print("\n\t\t\t[-] Argument Error: Please verify your inputs\n") exit() parser = argparse.ArgumentParser( description= 'This program allows to carry out a Fermat Factorization') parser.add_argument('-n', dest='n', type=int, help='RSA public key modulus', required=True) parser.add_argument('-e', dest='e', type=int, help='RSA public key exponent', required=True) params = parser.parse_args(args) attack_object = Attack(params) attack_object.fermat() elif attack == "4": print("\n\t\t\t ***** Bleichenbacher Attack *****") try: args = input( "\n\t\t[*] Arguments ([-h] -n modulus -e exponent -c ciphertext --host hostname -p port --error error padding message):\n\n\t\t\t" ).split() except: print("\n\t\t\t[-] Argument Error: Please verify your inputs\n") exit() parser = argparse.ArgumentParser( description= 'This program allows to carry out a Bleichenbacher Attack') parser.add_argument('-n', dest='n', type=int, help='RSA public key modulus (int)', required=True) parser.add_argument('-e', dest='e', type=int, help='RSA public key exponent (int)', required=True) parser.add_argument('-c', dest='c', type=int, help='ciphertext (int)', required=True) parser.add_argument('--host', dest='host', type=str, help='hostname', required=True) parser.add_argument('-p', dest='port', type=int, help='port', required=True) parser.add_argument('--error', dest='error', type=str, help='Oracle Padding Error', required=True) params = parser.parse_args(args) attack_object = Attack(params) attack_object.bleichenbacher() elif attack == "5": print("\n\t\t\t ***** Common Modulus Attack *****") try: args = input( "\n\t\t[*] Arguments [-h] -n common modulus -e1 first exponent -e2 second exponent -c1 first cipher -c2 second cipher:\n\n\t\t\t" ).split() except: print("\n\t\t\t[-] Argument Error: Please verify your inputs\n") exit() parser = argparse.ArgumentParser( description= 'This program allows to carry out a Common Modulus Attack') parser.add_argument('-n', dest='n', type=int, help='RSA public key modulus', required=True) parser.add_argument('-e1', dest='e1', type=int, help='First RSA public key exponent', required=True) parser.add_argument('-e2', dest='e2', type=int, help='Second RSA public key exponent', required=True) parser.add_argument('-c1', dest='c1', type=int, help='First ciphered text', required=True) parser.add_argument('-c2', dest='c2', type=int, help='Second ciphered text', required=True) params = parser.parse_args(args) attack_object = Attack(params) attack_object.comod() elif attack == "6": print("\n\t\t\t ***** Chosen Plaintext Attack *****") try: args = input( "\n\t\t[*] Arguments ([-h] -n modulus -e public_exponent -c ciphertext):\n\n\t\t\t" ).split() except: print("\n\t\t\t[-] Argument Error: Please verify your inputs\n") exit() parser = argparse.ArgumentParser( description= 'This program allows to carry out a Chosen Plaintext Attack') parser.add_argument('-n', dest='n', type=int, help='RSA public key modulus', required=True) parser.add_argument('-e', dest='e', type=int, help='first RSA public key exponent', required=True) parser.add_argument('-c', dest='c', type=int, help='ciphertext', required=True) params = parser.parse_args(args) params = parser.parse_args(args) attack_object = Attack(params) attack_object.chopla() elif attack == "a": print("\n\t\t\t ***** RSA Public Key parameters extraction *****") try: args = input("\n\t\t[*] Argument ([-h] -k K):\n\n\t\t\t").split() except: print("\n\t\t\t[-] Argument Error: Please verify your inputs\n") exit() if args[0] == '-k' and args[1] != '/': args[1] = getcwd() + "/" + args[1] parser = argparse.ArgumentParser( description= 'This program allows to extract the modulus and the exponent of an RSA public key (PEM)' ) parser.add_argument('-k', dest='k', type=str, help='path of the RSA public key', required=True) params = parser.parse_args(args) tool_object = Tool(params) tool_object.pubex() elif attack == "b": print("\n\t\t\t ***** RSA Private Key paramters extraction *****") try: args = input("\n\t\t[*] Argument ([-h] -k K):\n\n\t\t\t").split() except: print("\n\t\t\t[-] Argument Error: Please verify your inputs\n") exit() if args[0] == '-k' and args[1] != '/': args[1] = getcwd() + "/" + args[1] parser = argparse.ArgumentParser( description= 'This program allows to extract the parameters of an RSA private key (PEM)' ) parser.add_argument('-k', dest='k', type=str, help='path of the RSA private key', required=True) params = parser.parse_args(args) tool_object = Tool(params) tool_object.privex() elif attack == "c": print("\n\t\t\t ***** RSA Private Key constructor *****") try: args = input( "\n\t\t[*] Argument ([-h] -p first_factorization_element -q second_factorization_element -e public_exponent [-o output_file]):\n\n\t\t\t" ).split() except: print("\n\t\t\t[-] Argument Error: Please verify your inputs\n") exit() parser = argparse.ArgumentParser( description= 'This program allows to construct an RSA Private Key with its parameters' ) parser.add_argument('-p', dest='p', type=int, help='first element of the modulus factorization', required=True) parser.add_argument('-q', dest='q', type=int, help='second element of the modulus factorization', required=True) parser.add_argument('-e', dest='e', type=int, help='public exponent', required=True) parser.add_argument('-o', dest='o', type=str, help='output file') params = parser.parse_args(args) tool_object = Tool(params) tool_object.privkeyconstruct() elif attack == "d": print("\n\t\t\t ***** RSA Public Key constructor *****") try: args = input( "\n\t\t[*] Argument ([-h] -n modulus -e public_exponent [-o output_file]):\n\n\t\t\t" ).split() except: print("\n\t\t\t[-] Argument Error: Please verify your inputs\n") exit() parser = argparse.ArgumentParser( description= 'This program allows to construct an RSA Public Key with its parameters' ) parser.add_argument('-n', dest='n', type=int, help='modulus', required=True) parser.add_argument('-e', dest='e', type=int, help='public exponent', required=True) parser.add_argument('-o', dest='o', type=str, help='output file') params = parser.parse_args(args) tool_object = Tool(params) tool_object.pubkeyconstruct() elif attack == "e": print("\n\t\t\t ***** RSA Decipher *****") try: args = input( "\n\t\t[*] Argument ([-h] -n modulus -d private_exponent -c ciphertext):\n\n\t\t\t" ).split() except: print("\n\t\t\t[-] Argument Error: Please verify your inputs\n") exit() parser = argparse.ArgumentParser( description= 'This simple program allows to decipher a message using RSA') parser.add_argument('-n', dest='n', type=int, help='RSA public key modulus', required=True) parser.add_argument('-d', dest='d', type=int, help='RSA private key exponent', required=True) parser.add_argument('-c', dest='c', type=int, help='ciphertext', required=True) params = parser.parse_args(args) tool_object = Tool(params) tool_object.decipher() elif attack == "f": print("\n\t\t\t ***** RSA Encipher *****") try: args = input( "\n\t\t[*] Argument ([-h] -n modulus -e public_exponent -p plaintext):\n\n\t\t\t" ).split() except: print("\n\t\t\t[-] Argument Error: Please verify your inputs\n") exit() parser = argparse.ArgumentParser( description= 'This simple program allows to encipher a message using RSA') parser.add_argument('-n', dest='n', type=int, help='RSA public key modulus', required=True) parser.add_argument('-e', dest='e', type=int, help='RSA public key exponent', required=True) parser.add_argument('-p', dest='p', type=int, help='plaintext', required=True) params = parser.parse_args(args) tool_object = Tool(params) tool_object.encipher() else: choose("again")
def getData(): t = Tool("feverfinder", "Shivaal") return t.getTemperature()