Created
November 5, 2024 16:58
-
-
Save ThallyssonKlein/30f357288b547afed3e1b03125602d13 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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