#!/usr/bin/env python3 import sys try: from argon2 import PasswordHasher from argon2.low_level import Type except ImportError: print("Installing argon2-cffi...") import subprocess subprocess.check_call([sys.executable, "-m", "pip", "install", "argon2-cffi"]) from argon2 import PasswordHasher from argon2.low_level import Type # OWASP preset parameters ph = PasswordHasher( time_cost=3, memory_cost=65536, parallelism=4, hash_len=32, salt_len=16, type=Type.ID ) token = "gOvhQKzn47nfapPN6bDduFIM+HHYaIPu32n7/R/CjLZjfGFl1vUidpLByX1eu67s" hash_result = ph.hash(token) # Replace $ with $$ for .env file format env_hash = hash_result.replace('$', '$$') print("Argon2id hash generated successfully!") print() print("For .env file (with escaped $$):") print(env_hash) print() print("For config.json (no escaping):") print(hash_result)