what is wrong with this code:
this the hole sintax:
import bcrypt import hashlib import time import string
Sample password password = "mySecretP@ss"
def bcrypt_hash(password): salt = bcrypt.gensalt() return bcrypt.hashpw(password.encode(), salt)
def md5_hash(password): return hashlib.md5(password.encode()).hexdigest()
def sha1_hash(password): return hashlib.sha1(password.encode()).hexdigest()
def count_characters_and_punctuation(text): num_characters = len(text) num_punctuation = sum(1 for char in text if char in string.punctuation) return num_characters, num_punctuation
def main(): start_time = time.time() bcrypt_result = bcrypt_hash(password) bcrypt_time = (time.time() - start_time) * 1000 # Convert to milliseconds
start_time = time.time() md5_result = md5_hash(password) md5_time = (time.time() - start_time) * 1000
start_time = time.time() sha1_result = sha1_hash(password) sha1_time = (time.time() - start_time) * 1000
print(f"Password: {password}") print(f"BCrypt Hash: {bcrypt_result}") print(f"MD5 Hash: {md5_result}") print(f"SHA-1 Hash: {sha1_result}")
print(f"Time taken for BCrypt: {bcrypt_time:.6f} ms") print(f"Time taken for MD5: {md5_time:.6f} ms") print(f"Time taken for SHA-1: {sha1_time:.6f} ms")
bcrypt_char_count, bcrypt_punctuation_count = count_characters_and_punctuation(bcrypt_result) md5_char_count, md5_punctuation_count = count_characters_and_punctuation(md5_result) sha1_char_count, sha1_punctuation_count = count_characters_and_punctuation(sha1_result)
print(f"BCrypt: Character Count: {bcrypt_char_count}, Punctuation Count: {bcrypt_punctuation_count}") print(f"MD5: Character Count: {md5_char_count}, Punctuation Count: {md5_punctuation_count}") print(f"SHA-1: Character Count: {sha1_char_count}, Punctuation Count: {sha1_punctuation_count}")
if name == "main": main()
20 num_characters = len(text) ---> 21 num_punctuation = sum(1 for char in text if char in string.punctuation) 22 return num_characters, num_punctuation 23
TypeError: 'in ' requires string as left operand, not int