Last active
July 2, 2025 01:16
-
-
Save lastforkbender/7c26fe3ac3bf06091c5c5d9066ff1e82 to your computer and use it in GitHub Desktop.
Reverse Dimensional Trigonometric Tensor Encryption
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # // ////////////////////////\\ \ \ \-------\. . . . . . . . . . . . . . . . . | |
| # ////// /////////////////////\\\ \ \ \ . \. . . . . . . . . . . . . . _ | |
| # ////////// ///////////////// \\\ \ \ \ . \. . . . . . . . . . ___ | |
| # ////////////// ///////////// \\\> > > > R O S N E T < < < < | |
| # \\\\\\\\\\\\\\><\\\\ //////// / / /. /. . . . . __________ | |
| # \\\\\\\\\\><\\\\\\\\ //////// / / / . /. . . . ________________ | |
| # \\\\\\><\\\\\\\\\\\\ //////// / / / . /. . . _____________________ | |
| # \\><\\\\\\\\\\\\\\\\ //////// / / / ./. . __________________________ | |
| # \\\\\\\\\\\\\\\\\\\\//////// / / /-------/. . ______________________________ | |
| # ____________________________________________________________________________ | |
| # The reversed tensors encryption/decryption system. | |
| import importlib | |
| import hashlib | |
| import random | |
| import cmath | |
| import math | |
| import time | |
| import sys | |
| import os | |
| rosnet_mdl_dir = f'{os.path.dirname(os.path.abspath(__file__))}' | |
| #///////////////////////////////////////////////////////////////////////////// | |
| rosnet_private_key = 181002474261013468467035094080371485004600327025316803125 | |
| #///////////////////////////////////////////////////////////////////////////// | |
| class ROSNET: | |
| __slots__ = ['_key1', '_key2', '_key_set1', '_key_set2', '_locks', '_map', '_intA', | |
| '_intB', '_intC', '_intD', '_intE', '_intF', '_intG', '_intH', '_intI', | |
| '_tmap', '_tmap_f', '_amap', '_lpmap', '_lstA', '_lstB', '_lstC', '_lstD', | |
| '_lstE', '_lstF', '_lstG', '_lstH', '_lstI', '_strA', '_strB', '_strC', | |
| '_strD', '_strE', '_strF', '_strG', '_strH', '_strI', '_sgrd1', '_sgrd2', | |
| '_sgrd3', '_sgrd4', '_lb_r', '_cmpr1','_cmpr2', '_cmpr3', '_cmpr_set', | |
| '_res', '_ros_in', '_rc_1', '_rc_2', '_rc_3', '_private_key', '_sk', | |
| '_sks', '_smld_msk', '_psm'] | |
| def __init__(self): | |
| self._key1, self._key2, _cmpr_set, self._map = None, None, False, [] | |
| self._sgrd1 = [37, 51, 19, 82, 26, 40, 17, 56, 31, 46, 13, 74, 64, 28, 93, 61, | |
| 11, 66, 29, 78, 59, 15, 90, 42, 88, 24, 71, 33, 60, 10, 44, 39, | |
| 22, 16, 70, 18, 92, 63, 14, 47, 25, 62, 48, 35, 85, 65, 72, 20, | |
| 49, 77, 12, 52, 41, 73, 43, 30, 81, 50, 23, 58, 91, 38, 21, 68] | |
| self._sgrd3 = [2345, 1568, 3456] | |
| #..................................................................................... | |
| def rosnet_encrypt(self, data: str, key1: int, key2: int, k=9): | |
| if isinstance(data, str) and isinstance(key1, int) and isinstance(key2, int) and isinstance(k, int): | |
| if key1 > 0 and key2 > 0 and k > 0: | |
| self._key1, self._key2 = key1, key2 | |
| self.smldbox42_module_write() | |
| self.map_new_keys(k) | |
| self.map_signature_key() | |
| self.map_new_angles() | |
| self.map_rosnet_in(data) | |
| self.log_lock_sks_key_set(k) | |
| #print(f'\nMAIN KEYS SET:\n{self._key_set1}') | |
| #print(f'\nSIGNATURE KEYS SET(repeated trigonometric logX problem, quantum computer proof):\n{self._sks}') | |
| #print(f'\nPINS KEYS SET:\n{self._key_set2}') | |
| #print(f'\nSIGNATURE KEY = {self._sk}') | |
| #print(f'\nXYZM KEYS/DATA MERGE POINT MATRIX:\n{self._ros_in}') | |
| #print(f'\nANGLE LOCKS SET:\n{self._locks}') | |
| key1, key2 = None, None | |
| self.rosnet_encrypt_extA(data, k, 7) | |
| else: | |
| raise Exception(f'<rosnet err> no mas(key={key1}, pin={key2} and !{k})') | |
| else: self.rosnet_err(1, None) | |
| #..................................................................................... | |
| def rosnet_encrypt_extA(self, data: str, k: int, skl: int): | |
| self.set_sgrd4() | |
| self.set_sgrd2() | |
| self.lock_pin_smld_matrix(True, data, k, int(''.join(self.get_completed_signature_key_value())[:skl])) | |
| print(self._psm) | |
| print() | |
| self.unlock_pin_smld_matrix(k, int(''.join(self.get_completed_signature_key_value())[:skl])) | |
| print(self._psm) | |
| print() | |
| self.lock_pin_smld_matrix(False, 'Another data broker idiot agent that thinks he his smarter than G*d?', k, None) | |
| print(self._psm) | |
| #..................................................................................... | |
| def lock_pin_smld_matrix(self, isCipher: bool, data: str, k: int, csks: int): | |
| try: | |
| if 'rosnet_smld42' in sys.modules: | |
| import rosnet_smld42 | |
| except Exception as err2_module_rosnet_smld42: | |
| raise Exception('<rosnet err> rosnet_smld42 module was not imported; missing or corrupted') | |
| if isCipher: | |
| self._psm = [] | |
| self._smld_msk = rosnet_smld42.mask() | |
| self._lstB = [k for i in rosnet_smld42.lock(data, self._smld_msk) for j in i for k in j] | |
| print(self._lstB) | |
| print() | |
| for self._lstC in self._lstB: | |
| self._intA = max(self._lstC)%len(self._tmap_f) | |
| self._lstD = self._tmap_f[self._intA][sum(self._lstC)%len(self._tmap_f[self._intA][0])] | |
| self._intB = len(self._lstD) | |
| self._lstD = self._lstD[(self._intA+min(self._lstD[min(self._lstC)%self._intB]))%self._intB] | |
| self._intC = int(self._key_set2[self._sgrd4[csks%len(self._sgrd4)]%k])%self._sgrd2[max(self._lstD)%len(self._sgrd2)] | |
| self._psm.append((self._lstD, [(self._lstC[i]+self._intC)*(self._lstD[i]+self._intC) for i in range(3)])) | |
| else: self._psm = rosnet_smld42.unlock(data, self._smld_msk, self._psm) | |
| #..................................................................................... | |
| def unlock_pin_smld_matrix(self, k: int, csks: int): | |
| self._lstB = [] | |
| for self._lstA in self._psm: | |
| self._intA = int(self._key_set2[self._sgrd4[csks%len(self._sgrd4)]%k])%self._sgrd2[max(self._lstA[0])%len(self._sgrd2)] | |
| self._lstB.append([int((self._lstA[1][i]/(self._lstA[0][i]+self._intA))-self._intA) for i in range(3)]) | |
| self.reassemble_smld_lock_to_matrice() | |
| #..................................................................................... | |
| def reassemble_smld_lock_to_matrice(self): | |
| self._lstA, self._lstC, self._psm, self._intA, self._intB = [], [], [], 0, 0 | |
| for self._lstD in self._lstB: | |
| self._lstA.append(self._lstD) | |
| self._intA+=1 | |
| if self._intA > 2: | |
| self._lstC.append(self._lstA) | |
| self._intB+=1 | |
| self._lstA = [] | |
| self._intA = 0 | |
| if self._intB > 2: | |
| self._psm.append(self._lstC) | |
| self._lstC = [] | |
| self._intB = 0 | |
| #..................................................................................... | |
| def rosnet_decrypt(self, encrypted_points: list): | |
| pass | |
| #..................................................................................... | |
| def log_lock_sks_key_set(self, k: int): | |
| self._lstF, self._sks, self._intE = [], [], -1 | |
| for X in range(k): | |
| self._lstH, self._lstI, self._intF = [], [], 0 | |
| while 1: | |
| self._intE+=1 | |
| if self._locks[self._intE] > 2 and self._locks[self._intE+1] > 2: | |
| self._intF+=1 | |
| self._intE+=2 | |
| self._lstH.append(int(str(self._locks[self._intE])[:2])) | |
| self._lstI.append(int(str(self._locks[self._intE+1])[:2])) | |
| if self._intF == 12: | |
| break | |
| try: | |
| self.log_lock_key_set_cosine(self._lstH, self._lstI) | |
| self.log_lock_key_set_cosine_tangent(self._lstI) | |
| self._lstF = [str(int((self._lstC[i]**self._lstA[i])//(self._lstC[i]))) for i in range(len(self._lstC))] | |
| self._sks.append(str(int(self._key_set1[X])+int("".join(self._lstF).replace('0','')[:12]))[:12]) | |
| except Exception as no_mas_math_unrepresentable: | |
| X-=1 | |
| pass | |
| #..................................................................................... | |
| def log_lock_key_set_cosine(self, d: int, s: int): | |
| self._lstA = [] | |
| for self._intA in s: | |
| self._lstA.append([((t*self._intA)-(t-self._intA)/(math.pi*t))/self._intA for t in [math.log(x) for x in d]]) | |
| self.log_lock_key_set_remap_tensor([[math.sin(math.sqrt(t+1)) for t in self._lstA[0]]], [[math.cos(t) for t in self._lstA[0]]]) | |
| self._lstB = [r[::-1] for r in self._lstD] | |
| self._lstC = [(self._lstA[0][i]/self._lstB[0][i])/(i+1)/math.pi for i in range(len(self._lstA[0]))] | |
| for self._lstD in self._lstA[1:]: | |
| self._lstC = [(math.sqrt(self._lstC[i])/self._lstD[i])*math.log(self._lstD[i]) for i in range(len(self._lstC))] | |
| #..................................................................................... | |
| def log_lock_key_set_cosine_tangent(self, s: int): | |
| self._lstA = self._lstC[:] | |
| for self._intA in s: | |
| self._lstA = [(self._lstA[i]-self._intA)*self._intA*(math.log(d)/self._intA if d > 0 else 0) for i, d in enumerate(self._lstA)] | |
| self.log_lock_key_set_remap_tensor([[math.cos(t) for t in self._lstA]], [[math.sqrt(math.sqrt(t)) for t in self._lstA]]) | |
| self._lstB = [r[::-1] for r in self._lstD] | |
| self._lstA = [self._lstA[i]-self._lstB[0][i] for i in range(len(self._lstA))] | |
| self._lstA = [math.tan(t) for t in self._lstA] | |
| #..................................................................................... | |
| def log_lock_key_set_remap_tensor(self, t_a: list, t_b: list): | |
| self._lstD = [] | |
| for self._intA in range(len(t_a)): | |
| self._lstE = [] | |
| for self._intB in range(len(t_b[0])): | |
| self._intD = 0 | |
| for self._intC in range(len(t_b)): | |
| self._intD+=(t_a[self._intA][self._intC]+t_b[self._intC][self._intB]*self._intD) | |
| self._lstE.append(self._intD) | |
| self._lstD.append(self._lstE) | |
| #..................................................................................... | |
| def get_completed_signature_key_value(self) -> list: | |
| return [n for n in self._sk if n.isdigit()] | |
| #..................................................................................... | |
| def map_signature_key(self): | |
| self._sk = [] | |
| for pk in self._key_set2: | |
| self._lstC = self.signature_grid(str(rosnet_private_key), pk) | |
| self._sk.append(self._lstC('><')) | |
| self._sk = ''.join(self._sk) | |
| #..................................................................................... | |
| def signature_key(self, upk: str, pk: str) -> str: | |
| self._lstA = [] | |
| for self._intA in range(len(upk)): | |
| self._intB = int(pk[self._intA%len(pk)])+1 | |
| self._intC = ((self._intB-math.atan(int(pk)))-(math.pi+math.tan(self._intB)))%120 | |
| self._lstA.append(chr((ord(upk[self._intA])+int(((math.sqrt(self._intC+1)+self._intB)/3)*math.sin(math.radians(self._intC))))%240)) | |
| self._lstA = ''.join(self._lstA) | |
| #..................................................................................... | |
| def signature_grid(self, upk: str, pk: str) -> str: | |
| enoch = 0 | |
| def map_signature(V): | |
| nonlocal enoch | |
| self._lstB = [] | |
| self.signature_key(upk, pk) | |
| self._intE = len(self._lstA) | |
| for self._strA in V: | |
| enoch+=1 | |
| self._intF, self._intG = self.signature_grid_position((((enoch-(math.pi-int(pk))))*enoch)%360) | |
| self._lstB.append(self._lstA[(self._intF*7+self._intG)%self._intE]) | |
| return ''.join(self._lstB) | |
| return map_signature | |
| #..................................................................................... | |
| def signature_grid_position(self, a: float) -> int: | |
| self._intG = a%360 | |
| return int((self._intG/240)*7)%7, int((self._intG/120)*7)%7 | |
| #..................................................................................... | |
| def map_rosnet_in(self, data: str): | |
| if data.find(',') > -1: | |
| self._lstA, self._lstC, net, = data.split(','), [], 0 | |
| for ros in self._lstA: | |
| self._lstB = [int(n) for n in ros if n.isdigit()] | |
| if len(self._lstB) > 0: | |
| net+=sum(self._lstB) | |
| self._lstC.append(net) | |
| if len(self._lstC) > 0: | |
| self._ros_in, m_n = [self._lstC], max(self._lstC) | |
| self._lstB, self._lstC = [int(n) for n in self._key_set1], [int(n) for n in self._key_set2] | |
| for i in range(len(self._lstB)): | |
| self._ros_in.append([self.rosnet_in_calc(1, self._lstB[i], self._lstC[i], self._ros_in[0][j], i, m_n) for j in range(len(self._ros_in[0]))]) | |
| else: self.rosnet_err(4, None) | |
| else: self.rosnet_err(5, None) | |
| #..................................................................................... | |
| def rosnet_in_calc(self, mode: int, a, b=None, c=None, d=None, e=None): | |
| if mode == 1: | |
| l1 = (b+c)%(len(self._tmap_f)-1) | |
| l2 = (a+b+c)%(len(self._tmap_f[l1])-1) | |
| return math.ceil(math.log((a*c)/b)*self._tmap_f[l1][l2][c%(len(self._tmap_f[l1][l2])-1)][(d+1)%3]%e) | |
| #..................................................................................... | |
| def trace_angles(self, r: int, lb_amp: int, lck_rng: int, pnts_rng: int, ns_lvl: float): | |
| self._locks, self._lpmap, lobe_points, lpl, x, y, lobe_x, lobe_y = [], [], [], None, None, None, None, None | |
| self._amap[:len(self._amap)//pnts_rng] | |
| for a in self._amap: | |
| x, y, lobe_points_for_lobe = r*math.cos(a), r*math.sin(a), [] | |
| self._locks.append(random.randint(1, lck_rng)) | |
| self._lpmap.append([self.map_new_lobes(x, y, t, 5, 45, 2, lb_amp, ns_lvl) for t in range(pnts_rng)]) | |
| #..................................................................................... | |
| def map_new_lobes(self, x, y, t, tr: int, d: int, s: int, l_amp: int, n_lvl: float) -> tuple: | |
| lx, ly = x+l_amp*math.sin(tr*t/d*s*math.pi), y+l_amp*math.cos(tr*t/d*s*math.pi) | |
| lx+=random.uniform(-n_lvl, n_lvl) | |
| ly+=random.uniform(-n_lvl, n_lvl) | |
| return (lx, ly) | |
| #..................................................................................... | |
| def map_new_angles(self): | |
| # radius = cnt_r, points range = cnt_l/cnt_r, lobe amplitude = math.log(cnt_r), noise level = -(math.log(cnt_l/cnt_r)-math.pi) | |
| self._lstA = list(set([math.log((math.sqrt(sum(l)/math.pi)+1)/(abs(math.cos(l[2]/math.pi))+1)) for g in self._tmap_f for r in g for l in r])) | |
| self._lstA.sort() | |
| self._amap, cnt_r, cnt_l = [], 0, 0 | |
| for n in self._lstA: | |
| if n > 1.0: self._amap.append(n) | |
| else: | |
| cnt_r+=n | |
| cnt_l = (cnt_r+n+math.atan(cnt_r)+abs(cnt_l))-(n*n) | |
| self.trace_angles(math.ceil(cnt_r), math.floor(math.log(cnt_r)), int(self._key2), math.ceil(cnt_l/cnt_r), -(math.log(cnt_l/cnt_r)-math.pi)) | |
| self._lb_r = cnt_r | |
| #..................................................................................... | |
| def map_new_keys(self, k: int): | |
| self._key1, self._key2, self._intA = str(self._key1), str(self._key2), 0 | |
| if len(self._key1) == 12 and len(self._key2) == 4: | |
| self._tmap_f, self._key_set1, self._key_set2 = [], [], ['1'] | |
| for self._intB in range(k): | |
| self._key1, self._key2, self._map = self._key1.replace('0','1'), self._key2.replace('0','1'), [] | |
| for self._intC in [int(self._key1[i:i+2]) for i in range(11)]: | |
| for self._intD in range(4): self.map_new_keys_pin_connect() | |
| self.map_reversed_tensor(1) | |
| self.set_next_main_key() | |
| self.set_next_pin_key() | |
| else: | |
| if len(self._key1) != 12: self.rosnet_err(2, [self._key1]) | |
| if len(self._key2) != 4: self.rosnet_err(3, [self._key2]) | |
| self._key_set2.pop(0) | |
| #..................................................................................... | |
| def map_new_keys_pin_connect(self): | |
| self._intE = int(self._key2[self._intD]) | |
| self.eval_key_expr() | |
| self._intF = self._intA+self._intE+self._intC | |
| if self._intF < 0: | |
| if len(self._map) > 0: | |
| self._intF = (((int(self._key2)*999999)*self._intC)**(self._intD**(self._intD+9)))/math.pi | |
| else: | |
| raise Exception(f'<rosnet err> no mas(skd={self._intC} and/or +-#.# != len[-0.0])') | |
| self._map.append((complex(self._intC, self._intE+self._intC), math.log(self._intF))) | |
| self.set_key_expr_cycle() | |
| #..................................................................................... | |
| def set_key_expr_cycle(self): | |
| self._intA = str(self._intA).replace('.','').replace('e','').replace('+','').replace('-','')[::-1] | |
| if self._intA[0] == '0': self._intA = self._intA.replace('0', '1') | |
| self._intA = math.floor(int(self._intA[:12])/(self._intD+self._intC)) | |
| #..................................................................................... | |
| def eval_key_expr(self): | |
| self.map_grid_s1() | |
| if self._intD+1 == 1: self.map_key_expr_1() | |
| elif self._intD+1 == 2: self.map_key_expr_2() | |
| elif self._intD+1 == 3: self.map_key_expr_3() | |
| else: self.map_key_expr_4() | |
| #..................................................................................... | |
| def map_grid_s1(self): | |
| self._intG = self._intC*int(self._key2) | |
| if len(self._tmap_f) > 0: | |
| self._intH = len(self._tmap_f)-1 | |
| self._intG = int(str((sum(self._tmap_f[self._intH][self._intG%(len(self._tmap_f[self._intH])-1)][0])+self._intG)*(self._intD+1))[:2]) | |
| else: self._intG = int(str(self._intG*(self._intD+1))[:2]) | |
| #..................................................................................... | |
| def map_key_expr_1(self): | |
| if self._intE-self._intC > self._sgrd1[self._intG%64]: | |
| self._intA = math.sqrt((self._intA*self._intE)*self._intC**self._intE)*self._intC | |
| else: self._intA = ((math.log(self._intE**self._intC)-self._intC)+(self._intA*self._intC+self._intC))-self._intE-self._intC | |
| #..................................................................................... | |
| def map_key_expr_2(self): | |
| if self._intE-self._intC > self._sgrd1[self._intG%64]: | |
| self._intA = math.sqrt((self._intA*self._intE)*self._intC**self._intE)/self._intC | |
| else: self._intA = ((math.log(self._intE**self._intC)-self._intC)*(self._intA*self._intC+self._intC))+self._intE-self._intC | |
| #..................................................................................... | |
| def map_key_expr_3(self): | |
| if self._intE-self._intC > self._sgrd1[self._intG%64]: | |
| self._intA = math.sqrt((self._intA*self._intE)*self._intC**self._intE)+self._intC | |
| else: self._intA = ((math.log(self._intE**self._intC)+self._intC)*(self._intA+self._intC+self._intC))-self._intE+self._intC | |
| #..................................................................................... | |
| def map_key_expr_4(self): | |
| if self._intE-self._intC > self._sgrd1[self._intG%64]: | |
| self._intA = math.sqrt((self._intA*self._intE)*self._intC**self._intE)/self._intC | |
| else: self._intA = ((math.log(self._intE**self._intC)-self._intC)+(self._intA+self._intC-self._intC))+self._intE+self._intC | |
| #..................................................................................... | |
| def set_next_main_key(self): | |
| self._intG = str(sum([(l[0][0]+l[0][1]/(l[0][2]+1))-(l[0][2]-l[0][0]) for l in self._tmap])).replace('.', '').replace('-', '') | |
| self._intH = len(self._intG) | |
| if self._intH == 12: self._key1 = self._intG | |
| elif self._intH > 12: self._key1 = self._intG[:12] | |
| elif self._intH < 12: | |
| self._key1 = self._key1+self._intG | |
| if len(self._key1) > 12: self._key1 = self._key1[:12] | |
| self._key_set1.append(self._key1) | |
| #..................................................................................... | |
| def set_next_pin_key(self): | |
| self._intG = int(self._key2) | |
| self._intH = max(self._tmap[(self._intG+self._intA)%(len(self._tmap)-1)][0]) | |
| if self._intH < self._intG: | |
| self._key2 = str(((self._intG/math.pi)+self._intH)/(max(self._tmap[(self._intH+self._intA)%(len(self._tmap)-1)][0])))[:5].replace('-','').replace('.','') | |
| else: | |
| self._key2 = ((self._intH/math.pi)+self._intG)/(max(self._tmap[(self._intG+self._intA)%(len(self._tmap)-1)][0]))+int(self._key_set1[len(self._key_set1)-1]) | |
| self._key2 = str(self._key2)[1:5] | |
| if int(self._key2) > int(self._key_set2[len(self._key_set2)-1]): self._key2 = self._key2[::-1] | |
| self._key_set2.append(self._key2.replace('0','1')) | |
| #..................................................................................... | |
| def map_reversed_tensor(self, mode: int): | |
| # mode <1=MKST> | |
| if mode == 1: self.set_mrt_mkst() | |
| #..................................................................................... | |
| def set_mrt_mkst(self): | |
| self._tmap = [] | |
| self.set_abstract_tensor_pair(1) | |
| for i in range(len(self._lstA)): | |
| self._tmap.append([[j*k for j in self.get_reverse_tensor_exit(1, 1, i)] for k in self.get_reverse_tensor_exit(1, 2, i)]) | |
| self._tmap_f.append(self._tmap) | |
| self._lstA, self._lstB = None, None | |
| #..................................................................................... | |
| def set_abstract_tensor_pair(self, mode: int): | |
| if mode == 1: | |
| self._lstA = [(int((abs(t[0]+cmath.sqrt(t[0].real))*t[1]))%120, int((t[1]+t[0].imag)*t[0].real)%240) for t in self._map] | |
| self._lstB = [(int(abs((cmath.sqrt(t[0].real-t[0].imag)+t[1]))), int(1-((t[1]/t[0].real)-t[0].imag))) for t in self._map] | |
| #..................................................................................... | |
| def get_reverse_tensor_exit(self, mode: int, p: int, i: int) -> tuple: | |
| if mode == 1: | |
| if p == 1: | |
| return (self._lstA[i][0], self._lstB[i][1], math.ceil(math.atan(self._lstA[i][0])+math.cos(self._lstB[i][1]))) | |
| else: | |
| return (self._lstB[i][0], self._lstA[i][1], math.ceil(math.atan(self._lstB[i][0])+math.cos(self._lstA[i][1]))) | |
| #..................................................................................... | |
| def set_sgrd4(self): | |
| self._intA, self._intB, self._sgrd4 = 3099, 0, [3099] | |
| for self._intC in range(24): | |
| self._intA-=11 | |
| self._intB+=1 | |
| if self._intB == 8: | |
| self._sgrd4.append(self._intA) | |
| if self._intA != 1011: | |
| self._intA-=912 | |
| self._intB = 0 | |
| else: | |
| break | |
| self._sgrd4.append(self._intA) | |
| self._sgrd4 = self._sgrd4[::-1] | |
| #..................................................................................... | |
| def set_sgrd2(self): | |
| self._intA, self._intB, self._intC, self._intD, self._sgrd2 = 777, 0, 0, False, [777] | |
| for self._intE in range(54): | |
| if not self._intD: self._intB+=1 | |
| if self._intB < 7: self._intA-=10 | |
| else: | |
| if not self._intD: | |
| self._intA, self._intD = 696, True | |
| else: | |
| self._intC+=1 | |
| self._intA-=10 | |
| if self._intC == 8: | |
| self._sgrd2.append(self._intA) | |
| self._intC = 0 | |
| self._intA-=21 | |
| self._sgrd2.append(self._intA) | |
| self._sgrd2 = self._sgrd2[::-1] | |
| #..................................................................................... | |
| def compress(self): | |
| if not self._cmpr_set: self.set_compress_char_sets() | |
| for t in self._cmpr1: self._res = self._res.replace(t[0], t[1]) | |
| for t in self._cmpr2: self._res = self._res.replace(t[0], t[1]) | |
| for t in self._cmpr3: self._res = self._res.replace(t[0], t[1]) | |
| #..................................................................................... | |
| def decompress(self): | |
| if not self._cmpr_set: self.set_compress_char_sets() | |
| for t in self._cmpr3: self._res = self._res.replace(t[1], t[0]) | |
| for t in self._cmpr2: self._res = self._res.replace(t[1], t[0]) | |
| for t in self._cmpr1: self._res = self._res.replace(t[1], t[0]) | |
| #..................................................................................... | |
| def set_mixed_xyzm_char_sets(self): | |
| self._rc_1 = '@ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz^ 0123456789,;&:#<>/=+%?!.()[]*-÷×_~|{}`¿¡°《》¡□⁰ⁱ⁴⁵⁶⁷⁸⁹⁺⁻⁼⁽⁾ⁿ₀₁₂₃₄₅₆₇₈₉₊₋₌₍₎ₐₑₒₓₔₕₖₗₘₙₚₛₜ‡○◐◓◑◒●◉↺↻⇄⇆↔↚↛↮⇤⇥⇹⇇⇉⇋⇌↽⇁⇐⇒∝∓⌇⌘⍭⏅⏇׆אבגדהוזחטיךכלםמןנסעףפץצקרשת' | |
| self._rc_2 = 'æāăąªàáâãäęěĕəẹèéêëēėịıįīïîíìọœőōøõõôóòụűűůŭūüûúùŵŕřþťțţṭÿýỳŷƴşşṣ§§śŝðďđɗḍĝģğĥĵƙķ·łľľļĺźżžçćĉčɓṅŋňņńñ■ℼℊℍΩ⅄ⅈ⅏ↄ↞↠↶∪↷≲≳⋉⋊⋿◭◮⟺⟻⟼⟷⥦⥧⥨⥩⧔⧕⨂⩂⪏⪐⭙⌽⏄▽▼❲❳⋪⋫⟁∑☏' | |
| self._rc_3 = 'ᐂᐃᐄᐅᐆᐇᐈᐉᐊᐋᐌᐍᐎᐏᐐᐑᐒᐓᐔᐕᐖᐗᐘᐙᐚᐛᐜᐝᐞᐟᐠᐡᐢᐣᐤᐥᐦᐧᐨᐩᐪᐫᐬᐭᐮᐯᐰᐱᐲᐳᐴᐵᐶᐷᐸᐹᐺᐻᐼᐽᐾᐿᑀᑁᑂᑃᑄᑅᑆᑇᑈᑉᑊᑋᑌᑍᑎᑏᑐᑑᑒᑓᑔᑕᑖᑗᑘᑙᑚᑛᑜᑝᑞᑟᑠᑡᑢᑣᑤᑥᑦᑧᑨᑩᑪ' | |
| #..................................................................................... | |
| def set_compress_char_sets(self): | |
| self.set_compress_char_set1() | |
| self.set_compress_char_set2() | |
| self.set_compress_char_set3() | |
| self._cmpr_set = True | |
| #..................................................................................... | |
| def set_compress_char_set1(self): | |
| self._cmpr1 = [('111','a'),('222','à'),('333','â'),('444','ą'),('555','ä'), | |
| ('666','d'),('777','ð'),('888','ď'),('999','đ'),('000','ɗ'), | |
| ('011','y'),('022','ÿ'),('033','ý'),('044','ỳ'),('055','ŷ'), | |
| ('066','c'),('077','ç'),('088','ć'),('099','ĉ'),('001','č'), | |
| ('002','w'),('003','ŵ'),('004','ẁ'),('005','ẃ'),('006','ẅ'), | |
| ('007','z'),('008','ź'),('009','ż'),('-11','ž'),('-22','Ź'), | |
| ('-33','Ż'),('-44','Ž'),('-55','g'),('-66','ĝ'),('-77','ģ'), | |
| ('-88','ğ'),('-99','Ĝ')] | |
| #..................................................................................... | |
| def set_compress_char_set2(self): | |
| self._cmpr2 = [('11','r'), ('22','R'), ('33','ŕ'), ('44','ř'), ('55','+'), | |
| ('66','o'), ('77','O'), ('88','ó'), ('99','ô'), ('00','×'), | |
| ('.1','s'), ('.2','S'), ('.3','ś'), ('.4','ŝ'), ('.5','÷'), | |
| ('.6','n'), ('.7','N'), ('.8','ň'), ('.9','ņ'), ('.0','='), | |
| ('-1','e'), ('-2','E'), ('-3','ë'), ('-4','ę'), ('-5','<'), | |
| ('-6','t'), ('-7','T'), ('-8','ť'), ('-9','ț'), ('-0','>'), | |
| ('%1','ţ'), ('%2','Ť'), ('%3','Ţ'), ('%4','Ț'), ('%5','*'), | |
| ('%6','ē'), ('%7','Ę'), ('%8','é'), ('%9','ę'), ('%0','&'), | |
| ('01','ŋ'), ('02','Ṅ'), ('03','ń'), ('04','ñ'), ('05',':'), | |
| ('06','š'), ('07','Ş'), ('08','ş'), ('09','§'), ('%-','~'), | |
| ('10','õ'), ('20','Ö'), ('30','ō'), ('40','ọ'), ('50','^'), | |
| ('60','Ɍ'), ('70','Ř'), ('80','ŗ'), ('90','®'), ('0.','¿')] | |
| #..................................................................................... | |
| def set_compress_char_set3(self): | |
| self._cmpr3 = [('12','Σ'), ('13','ϊ'), ('14','ͽ'), ('15','μ'), ('16','⅐'), | |
| ('17','θ'), ('18','δ'), ('19','ΰ'), ('21','Ϩ'), ('23','⅑'), | |
| ('24','β'), ('25','ξ'), ('26','χ'), ('27','Ϫ'), ('28','⅓'), | |
| ('29','π'), ('31','ϻ'), ('32','Ϗ'), ('34','Є'), ('35','⅔'), | |
| ('36','ϕ'), ('37','Ͻ'), ('38','ϙ'), ('39','Д'), ('41','⅕'), | |
| ('42','Δ'), ('43','Ξ'), ('45','Џ'), ('46','И'), ('47','⅖'), | |
| ('48','λ'), ('49','Γ'), ('51','Ж'), ('52','Ы'), ('53','⅗'), | |
| ('54','ϕ'), ('56','ϐ'), ('57','Ю'), ('58','Я'), ('59','⅘'), | |
| ('61','Λ'), ('62','Ͱ'), ('63','Ϝ'), ('64','Ϡ'), ('65','⅙'), | |
| ('67','Π'), ('68','έ'), ('69','Ё'), ('71','Б'), ('72','⅚'), | |
| ('73','ϰ'), ('74','ζ'), ('75','Ϯ'), ('76','ν'), ('78','⅛'), | |
| ('79','ϖ'), ('81','Ј'), ('82','ϟ'), ('83','Њ'), ('84','⅜'), | |
| ('85','τ'), ('86','Ђ'), ('87','Θ'), ('91','Л'), ('92','⅝'), | |
| ('93','Υ'), ('94','ϱ'), ('95','ρ'), ('96','Ͽ'), ('97','⅞'), | |
| ('98','φ')] | |
| #..................................................................................... | |
| def check_rosnet_dirs(self): | |
| if not os.path.isdir(f'{rosnet_mdl_dir}/rosnet'): os.makedirs(f'{rosnet_mdl_dir}/rosnet') | |
| if not os.path.isdir(f'{rosnet_mdl_dir}/rosnet/_maftehot'): os.makedirs(f'{rosnet_mdl_dir}/rosnet/_maftehot') | |
| if not os.path.isdir(f'{rosnet_mdl_dir}/rosnet/_mechill'): os.makedirs(f'{rosnet_mdl_dir}/rosnet/_mechill') | |
| if not os.path.isdir(f'{rosnet_mdl_dir}/rosnet/_chazaq'): os.makedirs(f'{rosnet_mdl_dir}/rosnet/_chazaq') | |
| if not os.path.isdir(f'{rosnet_mdl_dir}/rosnet/_rishum'): os.makedirs(f'{rosnet_mdl_dir}/rosnet/_rishum') | |
| #..................................................................................... | |
| def smldbox42_module_write(self): | |
| self.check_rosnet_dirs() | |
| if not os.path.isfile(f'{rosnet_mdl_dir}/rosnet_smld42.py'): | |
| self._lstA = ['# SM42LDBOX; THIS MODULE IS AUTO-GENERATED BY THE ROSNET ENCRYPTION SYSTEM !!!DO NOT EDIT!!!\nimport random\nclass SMLD:\n def smld_chars_partition(self):\n'] | |
| self._lstA.append(' C1="@ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz^ 0123456789,;&:#<>/=+%?!.()[]*-÷×_~|{}`¿¡°《》¡□⁰ⁱ⁴⁵⁶⁷⁸⁹⁺⁻⁼⁽⁾ⁿ₀₁₂₃₄₅₆₇₈₉₊₋₌₍₎ₐₑₒₓₔₕₖₗₘₙₚₛₜ‡○◐◓◑◒●◉↺↻⇄⇆↔↚↛↮⇤⇥⇹⇇⇉⇋⇌↽⇁⇐⇒∝∓⌇⌘⍭⏅⏇׆אבגדהוזחטיךכלםמןנסעףפץצקרשת"\n') | |
| self._lstA.append(' C2="æāăąªàáâãäęěĕəẹèéêëēėịıįīïîíìọœőōøõõôóòụűűůŭūüûúùŵŕřþťțţṭÿýỳŷƴşşṣ§§śŝðďđɗḍĝģğĥĵƙķ·łľľļĺźżžçćĉčɓṅŋňņńñ■ℼℊℍΩ⅄ⅈ⅏ↄ↞↠↶∪↷≲≳⋉⋊⋿◭◮⟺⟻⟼⟷⥦⥧⥨⥩⧔⧕⨂⩂⪏⪐⭙⌽⏄▽▼❲❳⋪⋫⟁∑☏"\n') | |
| self._lstA.append(' C3="ᐂᐃᐄᐅᐆᐇᐈᐉᐊᐋᐌᐍᐎᐏᐐᐑᐒᐓᐔᐕᐖᐗᐘᐙᐚᐛᐜᐝᐞᐟᐠᐡᐢᐣᐤᐥᐦᐧᐨᐩᐪᐫᐬᐭᐮᐯᐰᐱᐲᐳᐴᐵᐶᐷᐸᐹᐺᐻᐼᐽᐾᐿᑀᑁᑂᑃᑄᑅᑆᑇᑈᑉᑊᑋᑌᑍᑎᑏᑐᑑᑒᑓᑔᑕᑖᑗᑘᑙᑚᑛᑜᑝᑞᑟᑠᑡᑢᑣᑤᑥᑦᑧᑨᑩᑪ"\n C1,L3,oc=list(f"{C1}{C2}"),len(C3),[]\n') | |
| self._lstA.append(' for _ in range(random.randint(random.randint(0,int(L3/2)),L3-1)):oc.append(C3[random.randint(0,L3-1)])\n oc = "".join(oc)\n C1 = list(f"{C1}{oc}")\n random.shuffle(C1)\n return C1\n') | |
| self._lstA.append(' def smld_sequence_partition(self,seq,chr_lst):\n seq=f"{seq}■■"\n f={c:0 for c in "".join(chr_lst)}\n for c in seq:\n if c in f:f[c]+=1\n return f\n def smld_encode(self,seq,chr_lst):\n') | |
| self._lstA.append(' f,clc,hn,hnc=self.smld_sequence_partition(seq,chr_lst),None,None,0\n cdi,seq,sl={char:idx for idx,char in enumerate(sorted(chr_lst,key=lambda x:f[x],reverse=True))},f"{seq}■■",len(seq)+2\n ds,idx=int((sl**(1/4))+1),0\n') | |
| self._lstA.append(' D4=[[[[None for _ in range(ds)]for _ in range(ds)]for _ in range(ds)]for _ in range(ds)]\n for i in range(ds):\n for j in range(ds):\n for k in range(ds):\n for l in range(ds):\n') | |
| self._lstA.append(' if idx<sl:\n char=seq[idx]\n hn=cdi[char]\n if hn>hnc:hnc=hn\n D4[i][j][k][l]=hn\n') | |
| self._lstA.append(' idx+=1\n else:\n for l in range(ds):\n while 1:\n clc=random.randint(0,hnc)\n') | |
| self._lstA.append(' if clc>99:\n D4[i][j][k][l]=clc\n break\n break\n return D4\n') | |
| self._lstA.append(' def smld_decode(self,seq,chr_lst,D4):\n f=self.smld_sequence_partition(seq,chr_lst)\n ids,seq,idx={idx:char for idx,char in enumerate(sorted(chr_lst,key=lambda x:f[x],reverse=True))},[],None\n') | |
| self._lstA.append(' for i in range(len(D4)):\n for j in range(len(D4[i])):\n for k in range(len(D4[i][j])):\n for l in range(len(D4[i][j][k])):\n idx=D4[i][j][k][l]\n') | |
| self._lstA.append(' if idx is not None:seq.append(ids[idx])\n seq="".join(seq)\n return seq[:seq.find("■")]\ndef mask():\n cls = SMLD()\n return cls.smld_chars_partition()\ndef lock(txt,msk_lst):\n cls = SMLD()\n') | |
| self._lstA.append(' return cls.smld_encode(txt,msk_lst)\ndef unlock(txt,msk_lst,mtx_lst):\n cls = SMLD()\n return cls.smld_decode(txt,msk_lst,mtx_lst)') | |
| with open(f'{rosnet_mdl_dir}/rosnet_smld42.py', 'w') as smld42MdlObjWrt: smld42MdlObjWrt.write(''.join(self._lstA)) | |
| self._lstA = None | |
| try: | |
| import rosnet_smld42 | |
| except Exception as err1_module_rosnet_smld42: | |
| raise Exception('<rosnet err> rosnet_smld42 module could not be imported') | |
| #..................................................................................... | |
| def get_rosnet_packet_data(self, enc: str, pckt_grp_id: int, pckt_ord_id: int) -> bytes: | |
| if pckt_grp_id < 256 and pckt_ord_id < 256: | |
| self._strA, self._strB = 'ROSNET_POLAR_4_2'.encode('utf-8'), enc.encode('utf-8') | |
| self._strC = (pckt_grp_id.to_bytes(1, byteorder='big')+ | |
| pckt_ord_id.to_bytes(1, byteorder='big')+ | |
| len(self._strA).to_bytes(1, byteorder='big')+ | |
| len(self._strB).to_bytes(4, byteorder='big')+ | |
| int(time.time()).to_bytes(4, byteorder='big')+self._strA) | |
| self._strA = self._strC+self._strB | |
| return self._strA+hashlib.md5(self._strA).digest()[:4]+bytes([0xFF]) | |
| else: | |
| raise Exception(f'<rosnet err> no mas(group_id={pckt_grp_id} +- order_id={pckt_ord_id} !=< 255)') | |
| #..................................................................................... | |
| def parse_rosnet_packet_data(self, pckt_data: bytes) -> list: | |
| self._intA, self._intB, self._intC = pckt_data[0], pckt_data[1], pckt_data[2] | |
| self._intD = int.from_bytes(pckt_data[3:7], byteorder='big') | |
| self._intE = int.from_bytes(pckt_data[7:11], byteorder='big') | |
| if self._intD < 256 and self._intE < 256: | |
| self._strA = pckt_data[11:11+self._intC].decode('utf-8') | |
| self._strB = pckt_data[11+self._intC:11+self._intC+self._intD].decode('utf-8') | |
| self._intF = pckt_data[11+self._intC+self._intD:11+self._intC+self._intD+4] | |
| self._intG = pckt_data[11+self._intC+self._intD+4] | |
| self._intH = hashlib.md5(pckt_data[:11+self._intC+self._intD]).digest()[:4] | |
| if self._intF != self._intH: | |
| raise Exception(f'<rosnet err> packet data checksum did not match({self._intF})') | |
| if self._intG != 0xFF: | |
| raise Exception(f'<rosnet err> packet data end marker incorrect({self._intG})') | |
| return [self._intA, self._intB, self._strA, self._intE, self._strB] | |
| else: | |
| raise Exception(f'<rosnet err> packet data group id or group order id invalid, exceeds 255 limit(group_id={self._intD}, order_id={self._intE})') | |
| #..................................................................................... | |
| def rosnet_err(self, err_code: int, feed_back: list): | |
| if err_code == 1: | |
| raise Exception('<rosnet err> invalid args') | |
| elif err_code == 2: | |
| raise Exception(f'<rosnet err> main key length invalid({len(feed_back[0])}), main key length must be 12 digits') | |
| elif err_code == 3: | |
| raise Exception(f'<rosnet err> pin key length invalid({len(feed_back[0])}), pin key length must be 4 digits') | |
| elif err_code == 4: | |
| raise Exception('<rosnet err> no rosnet data number(s) configuration to apply') | |
| elif err_code == 5: | |
| raise Exception('<rosnet err> no comma separations found for any data encryption') | |
| #______________________________________________________________________________________ | |
| class ROSNET_POINT(ROSNET): | |
| __slots__ = ['_pt_x', '_pt_y'] | |
| def __init__(self, pt_x, pt_y): | |
| self._pt_x = pt_x | |
| self._pt_y = pt_y | |
| def __repr__(self): | |
| return f"Point({self._pt_x}, {self._pt_y})" | |
| #______________________________________________________________________________________ | |
| class ROSNET_WEIERSTRASS_CURVE(ROSNET_POINT): | |
| __slots__ = ['_wc_a', '_wc_b', '_wc_m', '_wc_r'] | |
| def __init__(self, wsc_a, wsc_b): | |
| self._wc_a = wsc_a | |
| self._wc_b = wsc_b | |
| #..................................................................................... | |
| def wsc_on_curve(self, p: object) -> bool: | |
| if p is None: | |
| return True | |
| return p._pt_y**2 == p._pt_x**3+self._wc_a*p._pt_x+self._wc_b | |
| #..................................................................................... | |
| def wsc_double(self, p: object) -> object: | |
| return self.wsc_add(p, p) | |
| #..................................................................................... | |
| def wsc_add(self, p: object, q: object) -> object: | |
| if p is None: | |
| return q | |
| if q is None: | |
| return p | |
| if p._pt_x == q._pt_x and p._pt_y != q._pt_y: | |
| return None | |
| if p == q: self._wc_m = (3*p._pt_x**2+self._wc_a)/(2*p._pt_y) | |
| else: self._wc_m = (q._pt_y-p._pt_y)/(q._pt_x-p._pt_x) | |
| return ROSNET_POINT(self._wc_m**2-p._pt_x-q._pt_x, self._wc_m*(p._pt_x-x_r)-p._pt_y) | |
| #..................................................................................... | |
| def wsc_multiply(self, k: int, p: object) -> object: | |
| self._wc_r = None | |
| for i in range(k.bit_length()-1, -1, -1): | |
| self._wc_r = self.wsc_double(self._wc_r) | |
| if (k >> i) & 1: self._wc_r = self.wsc_add(self._wc_r, p) | |
| return self._wc_r | |
| #______________________________________________________________________________________ | |
| class ROSNET_ECC(ROSNET_WEIERSTRASS_CURVE): | |
| __slots__ = ['_ec_crvA', '_ec_crvB','_ec_crvC', '_ec_pntA', '_ec_pksA'] | |
| def __init__(self, crv): | |
| self._ec_crvA = crv | |
| #..................................................................................... | |
| def ecc_encode(self, src_pt: object, pk: int, x: int, y: int) -> object: | |
| self._ec_crvB = self._ec_crvA.wsc_multiply(pk, ROSNET_POINT(x, y)) | |
| self._ec_crvC = ROSNET_POINT(src_pt._pt_x+self._ec_crvB._pt_x, src_pt.pt_y+self._ec_crvB.pt_y) | |
| return self._ec_crvB, self._ec_crvC | |
| #..................................................................................... | |
| def ecc_decode(self, crvA: object, crvB: object) -> object: | |
| self._ec_pntA = self._ec_crvA.wsc_multiply(rosnet_private_key, crvA) | |
| return ROSNET_POINT(crvB._pt_x-self._ec_pntA._pt_x, crvB.pt_y-self._ec_pntA.pt_y) | |
| #______________________________________________________________________________________ | |
| def test(): | |
| main_key = 876943361852 # 12 digits | |
| pin_key = 4395 # 4 digits | |
| data = 'N.421:909:346118,S.428:162:803552,E.528:436:835054,W.525:728:940351' | |
| k = 9 # encryption keys strength(default=9) | |
| cls = ROSNET() | |
| cls.rosnet_encrypt(data, main_key, pin_key, k) | |
| test() | |
| #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>HAOLAM TIPESH<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< |
Author
Author
WHAT A AWESOME DAY TO BE AMERICAN
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If a mountain is in the way...don't hesitate. Move it out the way.