pylcg- Unnamed repository; edit this file 'description' to name the repository. |
git clone git://git.acid.vegas/-c.git |
Log | Files | Refs | Archive | README | LICENSE |
state.py (712B)
1 #!/usr/bin/env python 2 # PyLCG - Linear Congruential Generator for IP Sharding - Developed by acidvegas ib Python (https://github.com/acidvegas/pylcg) 3 # pylcg/state.py 4 5 import os 6 import tempfile 7 8 9 def save_state(seed: int, cidr: str, shard: int, total: int, lcg_current: int): 10 ''' 11 Save LCG state to temp file 12 13 :param seed: Random seed for LCG 14 :param cidr: Target IP range in CIDR format 15 :param shard: Shard number (1-based) 16 :param total: Total number of shards 17 :param lcg_current: Current LCG state 18 ''' 19 20 file_name = f'pylcg_{seed}_{cidr.replace("/", "_")}_{shard}_{total}.state' 21 state_file = os.path.join(tempfile.gettempdir(), file_name) 22 23 with open(state_file, 'w') as f: 24 f.write(str(lcg_current))