Example #1
0
def main_verification():
    global DB
    while True:
        query_time = get_now_time()
        # query_time = '2015-12-01 00:00:00'
        proxy_ip_info_list = get_from_db(query_time)
        while len(proxy_ip_info_list) != 0:
            for proxy_ip_info in proxy_ip_info_list:
                speed_cn, speed_com_A, speed_com_B, speed_cross = verification.verification(ip = proxy_ip_info[0], port = proxy_ip_info[1], mode = proxy_ip_info[2])
                if speed_cn + speed_com_A + speed_com_B + speed_cross == -4: # 验证失败
                    DB.db_delete(nature = 'proxy_ip', ip = proxy_ip_info[0], port = proxy_ip_info[1])

                else:
                    DB.db_update(
                        nature = 'proxy_ip',
                        ip = proxy_ip_info[0],
                        port = proxy_ip_info[1],
                        speed_cn = speed_cn,
                        speed_com_A = speed_com_A,
                        speed_com_B = speed_com_B,
                        speed_cross = speed_cross,
                        verification_time = get_now_time()
                    )

            DB.db_commit()
            proxy_ip_info_list = get_from_db(query_time)

        print get_now_time() + ' 验证数据'
        time.sleep(5*3600) # 每5个小时进行一次验证
Example #2
0
def ver_test(pos_list: ImagePairs, neg_list: ImagePairs,
             extractor: TensorflowExtractor):
    pos_feat = extract_list_feature(extractor, pos_list, len(pos_list),
                                    extractor.batch_size)
    neg_feat = extract_list_feature(extractor, neg_list, len(neg_list),
                                    extractor.batch_size)
    _acc, _std, _threshold, _pos, _neg, _accu_list = verification(
        pos_feat, neg_feat, 'cosine')
    return _accu_list, _acc, _std
Example #3
0
def saisieListe() :

    liste = []
    fin = False

    while not fin :
        a = input("entrez une valeur : ")
        if verification.verification(a) :
            liste.append(a)
        if a == "" :
            fin = True

    return liste
 def post(self):
     url = self.request.body
     face_id_emotion_dict, face_id_eye_open_dict = detection.detection(url)
     # print face_id_emotion_dict, face_id_eye_open_dict
     eye_close_id_list = [
         id for id in face_id_eye_open_dict.keys()
         if not face_id_eye_open_dict[id]
     ]
     # print eye_close_id_list
     sleep_ones = []
     for id in eye_close_id_list:
         for known_face_id in face_id_name_dict.keys():
             if verification.verification(id, known_face_id):
                 sleep_ones.append(face_id_name_dict[known_face_id])
     db.execute("""INSERT INTO log(ts, names) VALUES(UTC_TIMESTAMP, %s)""",
                ",".join(sleep_ones))
     self.write({"id": sleep_ones})
def main():
    """
    begin = time.time()
    #51751742255297
    print shank(182806019700907, 7253258872651, 48982943472108)
    print time.time() - begin
    """
    ### demo forgery
    from elgamal import elgamal
    from verification import verification
    ##
    A = elgamal(15)
    ca_a = verification(A.public_key)
    D = attack()
    ##
    text = "hello"
    sig = D.forge_signature(text, A.public_key)
    print sig
    print ca_a.verify(text, sig)
Example #6
0
 def __init__(self,
              start_day,
              last_day,
              fcst_day,
              loc,
              element,
              specify_day=True):
     self.start_day = start_day
     self.last_day = last_day
     self.fcst_day = fcst_day
     self.element = element
     self.specify_day = specify_day
     self.ensemble_list = []
     self.obs_list = []
     self.config = Config()
     self.location = loc
     loc_id = self.config.loc_dict[loc]
     self.DmoReader = LC_Reader(loc_id)
     self.V = verify.verification()
     self.outfolder = Config.output_folder + '/' + "verification" + "/"
     self.Score = []
     self.threshold = 0.0
Example #7
0
 def __init__(self,
              start_day,
              last_day,
              fcst_day,
              distribution,
              loc,
              element,
              specify_day=True):
     self.start_day = start_day
     self.last_day = last_day
     self.fcst_day = fcst_day
     self.element = element
     self.specify_day = specify_day
     self.coeff = []
     self.obs_list = []
     self.config = Config()
     loc_id = self.config.loc_dict[loc]
     self.DmoReader = LC_Reader(loc_id)
     self.V = verify.verification()
     self.distribution = distribution
     self.outfolder = Config.output_folder + '/' + "verification" + "/"
     self.Score = []
     self.threshold = 0.0  # filter which 0.0 m/s observation training data set
     self.location = loc
Example #8
0
    help='comma-separated Node:state pairs, e.g. Burglary:T,Color:blue')
parser.add_argument('q',
                    metavar='Query',
                    type=str,
                    help='Name of the query node')
parser.add_argument('i',
                    metavar='iter',
                    type=int,
                    help='No of iterations of MCMC')
parser.add_argument('-mb',
                    metavar='--MarkovBlanket',
                    type=str,
                    help='Name of node whose markov blanket is to be printed')
args = parser.parse_args()

#Create Network
network = Bnetwork(args.file, args.i)
#Verify Network
verify = verification(network)
verify.verify_data()
#Verify Evidence and Query

verify.check_parameters(network, args.e, [args.q])

#Run MCMC
answer = network.beta_mcmc(evidence=args.e, query=[args.q])
print(answer)
#If needed print Markov Blanket
if (args.mb):
    print(network.print_blanket(args.mb))
Example #9
0
def main():
    """
    DISTRIBUTE KEY
    """
    print "########## DISTRIBUTE KEY #################"
    # GIVE ALICE A KEY ... init with none key
    alice = elgamal()
    alice.create_key(10)
    # GIVE BOB KEY . .other  init with 10 bits key
    bob = elgamal(10)
    print "ALICE:\n", alice
    print "BOB:\n", bob
    print "################################"
    """
    END DISTRIBUTE KEY
    """
##########################################################################################################
    """
    ALICE'S TASK
    """
    print "########## ALICE's task ###########"
    # ALICE have a text
    text = "hello bob"
    print "TEXT: ", text
    # ALICE use public_key of BOB to encrypt that text
    cipher = bob.encrypt(text)
    #print "CIPHER: \n", cipher
    # give ALICE a pen
    alice_pen = signature(alice.private_key)
    #print alice_pen
    # create signature with ALICE's pen
    sig_of_alice = alice_pen.sign(text)
    #print "SIGNATURE: \n", sig
    ### alice send a pair contain cipher and her signature to bob
    pair = [cipher, sig_of_alice]
    print "PAIR[cipher, signature]: \n", pair    
    print "################################"
    """
    END ALICE'S TASK
    """
############################################################################################################
    """
    DARTH'S TASK
    """
    print "###### DARTH's task ###################"
    # DARTH have public_key of bob. He find private key
    darth = attack()
    k = darth.find_private_key(bob.public_key)
    print "DARTH found private key is: ", k
    pr = [bob.public_key[0], bob.public_key[1], k] # pr = [p, q, k]
    darth_crypto = elgamal()
    darth_crypto.set_key([],pr) ### darth only need private key to decrypt cipher
    print "Darth try to decrypt: ", darth_crypto.decrypt(pair[0])
    print "HAHAHAHAHAHAHA :)"
    print "################################"
    """
    DARTH'S TASK
    """
############################################################################################################
    """
    BOB'S TASK
    """
    print "########### BOB's task ###############"
    ###########bob receive the pair. bob take a accuracy of alice's signature
    ca_alice = verification(alice.public_key)
    t_text = bob.decrypt(cipher)
    print "BOB decrypt: ", t_text
    print "VERIFY: " ,ca_alice.verify(t_text,pair[1])
    """
Example #10
0
def query(qDes, qPts, index, pos_np, imgID_np, imgNum):

    # query the index file to get matched points
    score = [0] * imgNum  #np.zeros(shape=(imgNum, 1))
    index.nprobe = 5
    des = np.asarray(qDes).astype('float32')
    D, I = index.search(des, K)

    # compute the score for each image
    for i in range(qPts.shape[0]):
        for j in range(K):
            c_img = int(imgID_np[I[i, j], 0])
            score[c_img] = score[c_img] + 1

    st_score = sorted(score, reverse=True)
    # filter out the matched points
    selected_imgID = []
    matched_pts = []
    for i in range(imgNum):
        if score[i] > 0:  # all matched images are selected
            selected_imgID.append(i)
            matched_pts.append([])


#    for i in range(M):
#        selected_imgID.append(score.index[st_score[i]])
#        matched_pts.append([])

    for i in range(qPts.shape[0]):
        for j in range(K):
            c_idx = I[i, j]
            c_imgID = int(imgID_np[c_idx, 0])

            if c_imgID not in selected_imgID:
                continue

            c_p = selected_imgID.index(c_imgID)
            matched_pts[c_p].append([
                qPts[i, 0, 0], qPts[i, 0, 1], pos_np[c_idx, 0], pos_np[c_idx,
                                                                       1]
            ])

    # global verification for the matches
    final_id = []
    final_sim = []
    final_matches = []
    for i in range(len(selected_imgID)):
        if len(matched_pts[i]) <= 1:
            continue

        if const_params.__verification__:
            c_m = verification.verification(np.asarray(matched_pts[i]))
        else:
            c_m = np.asarray(
                matched_pts[i]
            )  #verification.verification(np.asarray(matched_pts[i]))

        if c_m.shape[0] > const_params.__match_thred__:
            final_id.append(selected_imgID[i])
            final_sim.append(c_m.shape[0])
            final_matches.append(np.asarray(matched_pts[i]))

    return final_id, final_sim, final_matches
Example #11
0
        pos_img, neg_img = pickle.load(open(args.data, 'rb'))
        #pos_img, neg_img = pickle.load(open(lfw_data, 'rb'), encoding='iso-8859-1')
    else:
        if args.test_set == 'lfw':
            pos_img, neg_img = load_image_paris(args.data, args.prefix)
        else:
            pos_img, neg_img = load_ytf_pairs(args.data, args.prefix)

    # crop image
    pos_img = crop_image_list(pos_img, image_size)
    neg_img = crop_image_list(neg_img, image_size)
    #print(type(pos_img[0][0]))
    #exit()
    # compute feature
    print('Extracting features ...')
    pos_list = extract_feature(extractor, pos_img)
    print('  Done positive pairs')
    neg_list = extract_feature(extractor, neg_img)
    print('  Done negative pairs')

    # evaluate
    print('Evaluating ...')
    precision, std, threshold, pos, neg = verification(pos_list,
                                                       neg_list,
                                                       dist_type=dist_type)
    _, title = os.path.split(extractor.weight)
    #draw_chart(title, output_dir, {'pos': pos, 'neg': neg}, precision, threshold)
    print('------------------------------------------------------------')
    print('Precision on %s : %1.5f+-%1.5f \nBest threshold   : %f' %
          (args.test_set, precision, std, threshold))
Example #12
0
#  Romain GAUD
#  11/24/2020
#  Fonction : verifier la saisie de l'utilisateur
from verification import verification


print("\nEntrer ici une date sous la forme jj/mm/aaaa")
val = input("Date : ")
   
if verification(val):
    print("\n  -  La date %s est valide  -  "%(val,))
else:
    print("\n   - La date %s n'est pas valide - " %(val,))
Example #13
0
from verification import verification
import webbrowser
import os

print("Enter variant:")
variant = verification(1, 6)
if variant == 1:
    print("Hello world!")
if variant == 2:
    print("My name is Danil, i'm 22 old, and i wanna learn python.")
if variant == 3:
    print(os.name)
if variant == 4:
    print("Enter your name :")
    b = str(input())
    print("Hello,", b, "!")
if variant == 5:
    print("Change a variant (1-6)")
    variant = int(input())
if variant == 6:
    webbrowser.open("https://youtu.be/dQw4w9WgXcQ")