mirror of
https://github.com/csd4ni3l/loginween.git
synced 2025-11-05 05:58:10 +01:00
26 lines
706 B
Python
26 lines
706 B
Python
import json, random, time
|
|
|
|
systemrandom = random.SystemRandom()
|
|
|
|
class Pattern():
|
|
def __init__(self, data: list[tuple]):
|
|
self.data: list[tuple] = data
|
|
|
|
@classmethod
|
|
def from_str(cls, string):
|
|
return cls([tuple(map(int, pos.split(","))) for pos in json.loads(string)])
|
|
|
|
@classmethod
|
|
def from_json_str(cls, data):
|
|
return cls(list(map(tuple, json.loads(data))))
|
|
|
|
def to_json_str(self):
|
|
return json.dumps(self.data)
|
|
|
|
def __eq__(self, value):
|
|
if not isinstance(value, Pattern):
|
|
return False
|
|
|
|
time.sleep(systemrandom.uniform(0.001, 0.5)) # prevent timing attacks
|
|
|
|
return set(self.data) == set(value.data) |