Skip to content

Instantly share code, notes, and snippets.

@ThallyssonKlein
Created November 5, 2024 16:58
Show Gist options
  • Save ThallyssonKlein/30f357288b547afed3e1b03125602d13 to your computer and use it in GitHub Desktop.
Save ThallyssonKlein/30f357288b547afed3e1b03125602d13 to your computer and use it in GitHub Desktop.
import bcrypt
def generate_hashed_password(plain_password):
salt = bcrypt.gensalt()
hashed_password = bcrypt.hashpw(plain_password.encode('utf-8'), salt)
return hashed_password.decode('utf-8')
def main():
num_users = int(input("Quantos usuários você deseja adicionar? "))
inserts = []
for _ in range(num_users):
username = input("Digite o nome de usuário: ")
password = input("Digite a senha: ")
hashed_password = generate_hashed_password(password)
inserts.append(f"INSERT INTO users (username, password) VALUES ('{username}', '{hashed_password}');")
print("\nComandos SQL gerados:")
for insert in inserts:
print(insert)
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment