import x.crypto.chacha20poly1305
import crypto.argon2
import rand

fn main() {
    password := 'ilovebears'.bytes()
    message := 'wow! not a secret'.bytes()
    salt := rand.bytes(16)!

    key := argon2.id_key(
        password, 
        salt, 
        argon2.default_time, 
        argon2.default_memory, 
        argon2.default_threads, 
        argon2.default_key_len
    )!

    nonce := rand.bytes(12) or { panic(err) }
    aad := 'wojtek'.bytes()

    ciphertext := chacha20poly1305.encrypt(message, key, nonce, aad)!
    plaintext := chacha20poly1305.decrypt(ciphertext, key, nonce, aad)!

    assert plaintext == message
}