Example #1
0
def authkey(
        auth="WyI0MzQ5NyIsIm8rRGJXcjBJNUo3aWYwUk5URUJNaXdZZWdHSlZZbmwxMHFoK2JEQ0ciXQ==",
        product_id=None,
        rsa_pub_key="<RSAKeyValue><Modulus>n5Q5BtZIlprf+d74p2YmQT1ZnRrCFGqt9JtAzO29/eNbzaM9rFZ5IaD8iIqbc0gVrE2ZFA0tfCtzeAVdV6MlaDaaqexNIZARMBK4dk9AEZb9kAOzdUXZNLv6O3+HyZg6bV75Gj6xFY17YUCefDol5Fyn0Z072lFXUV1DArgb+i2r/YDBI/QTS0crHMUS7iXdlWRk1DdGABvrvtoR78P6+uci5njxjlkniByBODyRMAoml1zk9YBRrCEXi6HLxlurd2Y29QizHRTCACCZP3WsNSiyKZqgKOOjUnZyi+hMX8+W06tcofsjjbKa7D+csFQi0MeL5juiNM3om0vtSD6zjQ==</Modulus><Exponent>AQAB</Exponent></RSAKeyValue>",
        key=None,
        pathtokey=None,
        pathtovaluecsv_key=None,
        using_permanent_key=False,
        valueser_key="",
        path_mc_id="",
        ser_key=""):
    """ auth key """
    result = Key.activate(token=auth,\
                   rsa_pub_key=rsa_pub_key,\
                   product_id=product_id, \
                   key=key,\
                   machine_code=Helpers.GetMachineCode()
                   )
    if (result[0] == None or not Helpers.IsOnRightMachine(
            result[0])) and using_permanent_key == False:
        # an error occurred or the key is invalid or it cannot be activated
        # (eg. the limit of activated devices was achieved)
        # in this case not connect server
        if "11001" in result[1]:
            return _active_or_not(pathtokey=pathtokey,
                                  pathtovaluecsv_key=pathtovaluecsv_key)
        # case for not actived
        else:
            write_key(path=pathtokey)
            key = load_key(pathtokey)
            encrypt(filename=pathtovaluecsv_key,
                    key=key,
                    nametow=b"Not actived")
            return [False]

    elif using_permanent_key:
        return __check_permanent_key(path_mc_id=path_mc_id,
                                     valueser_key=valueser_key,
                                     pathtokey=pathtokey,
                                     ker_ser=key,
                                     ser_key=ser_key)

    else:
        # everything went fine if we are here!
        write_key(path=pathtokey)
        key = load_key(pathtokey)
        encrypt(filename=pathtovaluecsv_key, key=key, nametow=b"actived")
        license_key = result[0]
        return [True, str(license_key.expires)]
Example #2
0
def _active_or_not(pathtokey, pathtovaluecsv_key):
    """ check if it can not connect to server """
    key = load_key(pathtokey)
    k = decrypt(filename=pathtovaluecsv_key, key=key)
    if k == "actived":
        return [True]
    else:
        return [False]
    def _valid_key(self):
        """ check valid key """
        x1 = self.can_en.get()
        key = load_key(self.ser_key)
        try:
            if decrypt(filename=self.valueser_key, key=key) == x1:
                encrypt(filename=self.path_mc_id,
                        key=key,
                        nametow=mcwd_id().encode('utf_8'))
        except:
            pass
        aucre = authkey(product_id=self.product_id,
                        key=str(x1),
                        pathtokey=self.pathtokey,
                        pathtovaluecsv_key=self.pathtovaluecsv_key,
                        path_mc_id=self.path_mc_id,
                        valueser_key=self.valueser_key,
                        using_permanent_key=self.using_permanent_key,
                        ser_key=self.ser_key)
        label1 = tk.Label(self.__tktk,
                          text="the key is invalid or it can not be activated",
                          fg="red")

        if aucre[0] == False:
            label1.place(relx=0.5, rely=0.65, anchor=tk.CENTER)
        else:
            write_key(self.ser_key)
            key = load_key(self.ser_key)
            encrypt(filename=self.valueser_key,
                    key=key,
                    nametow=str(x1).encode('utf_8'))

            encrypt(filename=self.path_mc_id,
                    key=key,
                    nametow=mcwd_id().encode('utf_8'))

            tk.messagebox.showinfo(
                "Activation Wizard",
                "Activation successful, License expires: " + aucre[1])
            self.__tktk.quit()
Example #4
0
def __check_permanent_key(path_mc_id, valueser_key, pathtokey, ker_ser,
                          ser_key):
    key = load_key(ser_key)
    try:
        key_value_de = decrypt(filename=valueser_key, key=key)
    except:
        key_value_de = ""

    try:
        idmc = decrypt(filename=path_mc_id, key=key)
    except:
        idmc = ""
    if mcwd_id() == idmc and key_value_de == ker_ser:
        return [True, "The key is used indefinitely"]
    else:
        return [False]
Example #5
0
    def getSquareRoot(self):
        x1 = self.entry1.get()
        #label1 = tk.Label(root, text= float(x1)**0.5)
        aucre = authkey(product_id=7018,
                        key=str(x1),
                        pathtokey=self.pathtokey,
                        pathtovaluecsv_key=self.pathtovaluecsv_key)
        label1 = tk.Label(root,
                          text="the key is invalid or it can not be activated",
                          fg="red")

        if aucre == False:
            self.canvas1.create_window(200, 230, window=label1)
        else:
            write_key(self.ser_key)
            key = load_key(self.ser_key)
            encrypt(filename=self.valueser_key,
                    key=key,
                    nametow=str(x1).encode('utf_8'))
            self.canvas1.destroy()
            self.guiforgd()
    def __init__(self,
                 tktk=None,
                 pathtokey=None,
                 pathtovaluecsv_key=None,
                 ser_key=None,
                 valueser_key=None,
                 product_id=7018,
                 using_permanent_key=False,
                 path_mc_id=None,
                 **kw):
        self.__tktk = tktk
        self.result = False
        key = load_key(ser_key)

        try:
            valueser_key_de = decrypt(filename=valueser_key, key=key)
        except:
            valueser_key_de = None

        aucre = authkey(product_id=product_id,
                        key=valueser_key_de,
                        pathtokey=pathtokey,
                        pathtovaluecsv_key=pathtovaluecsv_key,
                        using_permanent_key=using_permanent_key,
                        path_mc_id=path_mc_id,
                        valueser_key=valueser_key,
                        ser_key=ser_key)
        if aucre[0] == False:
            guiforinser(tktk=tktk,
                        pathtokey=pathtokey,
                        pathtovaluecsv_key=pathtovaluecsv_key,
                        ser_key=ser_key,
                        valueser_key=valueser_key,
                        using_permanent_key=using_permanent_key,
                        product_id=product_id,
                        path_mc_id=path_mc_id,
                        **kw)
        else:
            self.result = True