def check_log_in_telegram(self): telebot_inst: NeoChatBot telebot_inst = self.global_args.get("telebot_inst", None) if telebot_inst == None: raise Exception("telebot_inst is None") session_no = session.get(tag_session_no,"") auth_info = telebot_inst.auth_info if auth_info == None: raise Exception(f"auth is not excute") session_status = auth_info["session_status"] auth = auth_info["auth"] tele_session_no = auth_info["session_no"] if tele_session_no != session_no: raise Exception(f"session_no:{session_no} is diffrent from {tele_session_no}") if session_status != "done" or not auth_info["auth"]: raise Exception(f"session_no:{session_no} session_status:{session_status} and auth:{auth}") auth_info["session_status"] = "init" session[tag_session_no] = "" calc_hash = crypto_util_bin.sha256(b'111') print('calc_hash',tohexstr(calc_hash)) user_info = neoutil.Struct() user_info.name = "신원석" return self.comm_confirm(user_info, calc_hash, calc_hash)
def update_detail_info(self): assert self.main_data_dash_data != None assert self.filterd_ids != None self.main_data = copy.deepcopy(self.main_data_dash_data) all_data = self.main_data['all_data'] for id in self.filterd_ids: contents = all_data.get(id) if not contents: continue contents: dict #status = contents['status'] #if status != 'ico_updt':continue tmp = self.update_detail_by_Id(id) #tmp = self.get_dict_from_id(id) if tmp == None: continue new_obj = copy.deepcopy(self.default_obj) new_obj.update(**tmp) new_obj['hash'] = tohexstr( crypto_util_bin.sha256(json.dumps(tmp).encode())) print(new_obj) contents.update(**new_obj) #self.mapTopid.append(new_obj) pass
def log_in(self): print("log_in data", self.data.id,self.data.hash_passwd) list_user_info = self.select("""SELECT seq, usr_uid, id, fb_userid, name, pwd, rn, rn_srv, etc_info FROM neo_pwinfo.user where id='{id}';""".format(id=self.data.id)) print(tag_redirect, redirect) if len(list_user_info) ==0: raise Exception("user is not in db") user_info = neoutil.Struct(**list_user_info[0]) print("hash", tohexstr(crypto_util_bin.sha256('tofhdna1pwd'.encode()))) print("hash pwd", user_info.pwd) pwd = user_info.pwd print("input_hash",tohexstr(self.server_random+ tobytes(pwd))) calc_hash = crypto_util_bin.sha256(self.server_random+ tobytes(pwd)) return self.comm_confirm(user_info,calc_hash,self.data.hash_passwd)
def log_in_facebook(self): print("log_in_facebook data", self.data.fb_userid,self.data.hash_hint_passwd) list_user_info = self.select("""SELECT seq, usr_uid, id, fb_userid, name, pwd, rn, rn_srv, etc_info FROM neo_pwinfo.user where fb_userid='{fb_userid}';""".format(fb_userid=self.data.fb_userid)) redirect = neoutil.get_safe_mapvalue(session, tag_redirect, "/main.neo") print(tag_redirect, redirect) if len(list_user_info) ==0: raise Exception("user is not in db") value = self.map_hint[self.pre_key] user_info = neoutil.Struct(**list_user_info[0]) calc_hash = crypto_util_bin.sha256(self.server_random+ value.encode()) print('calc_hash',tohexstr(calc_hash)) print('hash_hint_passwd', self.data.hash_hint_passwd) return self.comm_confirm(user_info, calc_hash, self.data.hash_hint_passwd)
def hash_dash(self): return tohexstr( crypto_util_bin.sha256( json.dumps(self.main_data_dash_data).encode()))