gitscope
https://dev.kronoz.win/r/marzneshin.git
app/utils/keygen.py · v0.5.4
Source
1 a47eb4c Dawsh 2y ago import xxhash
2 a47eb4c Dawsh 2y ago import uuid
3 f2ddb05 m0x61h0x64i 2y ago from app.config.env import AuthAlgorithm, AUTH_GENERATION_ALGORITHM
4 a47eb4c Dawsh 2y ago
5 01cdf2e Dawsh 2y ago
6 a47eb4c Dawsh 2y ago def gen_uuid(key: str) -> str:
7 f2ddb05 m0x61h0x64i 2y ago if AUTH_GENERATION_ALGORITHM == AuthAlgorithm.PLAIN:
8 f2ddb05 m0x61h0x64i 2y ago return str(uuid.UUID(key))
9 f2ddb05 m0x61h0x64i 2y ago else:
10 f2ddb05 m0x61h0x64i 2y ago return str(uuid.UUID(bytes=xxhash.xxh128(key.encode()).digest()))
11 a47eb4c Dawsh 2y ago
12 01cdf2e Dawsh 2y ago
13 a47eb4c Dawsh 2y ago def gen_password(key: str) -> str:
14 f2ddb05 m0x61h0x64i 2y ago if AUTH_GENERATION_ALGORITHM == AuthAlgorithm.PLAIN:
15 f2ddb05 m0x61h0x64i 2y ago return key
16 f2ddb05 m0x61h0x64i 2y ago else:
17 f2ddb05 m0x61h0x64i 2y ago return xxhash.xxh128(key.encode()).hexdigest()