Skip to content

Instantly share code, notes, and snippets.

@daleffe
Created July 3, 2024 02:02
Show Gist options
  • Save daleffe/f81dbc36ff6b289663f210a7e1201d6c to your computer and use it in GitHub Desktop.
Save daleffe/f81dbc36ff6b289663f210a7e1201d6c to your computer and use it in GitHub Desktop.
Mosquitto password generator
#!/usr/bin/python3.9
try:
import passlib.hash
except Exception as e:
print("Unable to start Mosquitto Password Generator",e)
exit
def mosquitto_passwd(passwd):
SALT_SIZE = 12
ITERATIONS = 101
digest = passlib.hash.pbkdf2_sha512.using(salt_size=SALT_SIZE, rounds=ITERATIONS).hash(passwd).replace("pbkdf2-sha512", "7").replace(".", "+")
return digest + "=="
if __name__ == '__main__':
print(mosquitto_passwd('teste'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment