Correct implementation of encryption function I wrote a simple encryption function that uses argon2d as the KDF and XChaCha20-Poly1305 as the AEAD. Since it is very easy to not get things right when dealing with encryption, I would appreciate if someone could review my script and tell me if it has any vulnerabilities and could be used in the real world to encrypt real data.
import argon2
from Cryptodome.Cipher import ChaCha20_Poly1305
import secrets

def encrypt(password, data):
    salt = secrets.token_bytes(32)
    nonce = secrets.token_bytes(24)
    
    key = argon2.low_level.hash_secret_raw(secret=password, salt=salt, time_cost=3, memory_cost=1000000, parallelism=4, hash_len=32, type=argon2.low_level.Type.D, version=19)
    
    cipher = ChaCha20_Poly1305.new(key=key, nonce=nonce)
    
    ciphertext, tag = cipher.encrypt_and_digest(data)
    
    return salt + nonce + ciphertext + tag
You can add annotations in function parameters, like password: str and so on.