Exemplo n.º 1
0
    def run(self):
        '''
        start process

        @return void
        '''

        try:
            from modules.otp import Otp
            gett = self.que[0].get    # read
            putt = self.que[1].put_nowait    # write
            crypto = Otp()
            boool = self.info[2][0] == 'E'
            f_iv = 'iv_%s' % self.info[5][IV_S:IV_E]

            if(boool):
                file = open(f_iv, 'wb')
                std = file.write
                code = crypto.encrypt
            else:
                file = open(f_iv, 'rb')
                std = file.read
                code = crypto.decrypt

            while True:
                # data from read
                data, seq = gett()
                if(not data):
                    break
                l_data = len(data)
                if(boool):
                    ivv = u_ut_iv(l_data, 'S', True)
                    std(ivv)
                else:
                    ivv = std(l_data)
                putt((code(data, ivv), seq))

            file.close()
            self.que[0].cancel_join_thread()
            self.que[1].close()
        except Empty:
            pass
        except ImportError:
            pass
        except AttributeError:    # no selv.if
            self.que[1].put_nowait((False, 0))
        except KeyboardInterrupt:    # Ctrl + C
            pass

        return
Exemplo n.º 2
0
    def run(self):
        '''
        start process

        @return void
        '''

        try:
            from modules.otp import Otp
            gett = self.que[0].get  # read
            putt = self.que[1].put_nowait  # write
            crypto = Otp()
            boool = self.info[2][0] == 'E'
            f_iv = 'iv_%s' % self.info[5][IV_S:IV_E]

            if (boool):
                file = open(f_iv, 'wb')
                std = file.write
                code = crypto.encrypt
            else:
                file = open(f_iv, 'rb')
                std = file.read
                code = crypto.decrypt

            while True:
                # data from read
                data, seq = gett()
                if (not data):
                    break
                l_data = len(data)
                if (boool):
                    ivv = u_ut_iv(l_data, 'S', True)
                    std(ivv)
                else:
                    ivv = std(l_data)
                putt((code(data, ivv), seq))

            file.close()
            self.que[0].cancel_join_thread()
            self.que[1].close()
        except Empty:
            pass
        except ImportError:
            pass
        except AttributeError:  # no selv.if
            self.que[1].put_nowait((False, 0))
        except KeyboardInterrupt:  # Ctrl + C
            pass

        return
Exemplo n.º 3
0
    def __init__(self, who, info, que):
        Process.__init__(self)
        self.info = info
        self.que = que
        self.who = who

        f_iv = 'iv_%s' % info[5][IV_S:IV_E]
        if(who[0] == 0 and self.info[2][0] == 'E'):
            self.ivv = u_ut_iv(info[1], 'S')
            with open(f_iv, 'wb') as file:
                file.write(dumps(self.ivv))
        else:
            try:
                with open(f_iv, 'rb') as file:
                    self.ivv = loads(file.read())
            except FileNotFoundError:
                self.ivv = None
Exemplo n.º 4
0
    def __init__(self, who, info, que):
        Process.__init__(self)
        self.info = info
        self.que = que
        self.who = who

        f_iv = 'iv_%s' % info[5][IV_S:IV_E]
        if (who[0] == 0 and self.info[2][0] == 'E'):
            self.ivv = u_ut_iv(info[1], 'S')
            with open(f_iv, 'wb') as file:
                file.write(dumps(self.ivv))
        else:
            try:
                with open(f_iv, 'rb') as file:
                    self.ivv = loads(file.read())
            except FileNotFoundError:
                self.ivv = None