#!/usr/bin/env python

import hashlib
import os

num_rounds = 500_000
salt = os.urandom(16)

pwhash = hashlib.pbkdf2_hmac(
    "sha256",
    input("Please set your password: ").encode(),
    salt,
    num_rounds
)

pwlogin = hashlib.pbkdf2_hmac(
    "sha256",
    input("Login password: ").encode(),
    salt,
    num_rounds
)

if pwlogin == pwhash:
    print("Permission granted")
else:
    print("Permission denied")
