---
title: "Discussion on \"Generate Passwords and Passphrases Correctly in Python: secrets, Modulo Bias and Exact Entropy\" | Hashnode"
description: "Discussion on \"Generate Passwords and Passphrases Correctly in Python: secrets, Modulo Bias and Exact Entropy\". Why random and byte % len are the wrong tools, how to require character classes without skewing the output, and a tested ~100-line stdlib CLI that prints how many bits you actually got"
url: "https://hashnode.com/posts/generate-passwords-and-passphrases-correctly-in-python-secrets-modulo-bias-and-exact-entropy/6af26f84322f75c4fcf71684"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Generate Passwords and Passphrases Correctly in Python: secrets, Modulo Bias and Exact Entropy](https://jadenvo259.hashnode.dev/generate-passwords-and-passphrases-correctly-in-python-secrets-modulo-bias-and-exact-entropy?utm_source=hashnode&utm_medium=feed)

Why random and byte % len are the wrong tools, how to require character classes without skewing the output, and a tested ~100-line stdlib CLI that prints how many bits you actually got

1d ago · 8 min read · jadenvo259.hashnode.dev  
Read the article

-   [#python](https://hashnode.com/tag/python)
-   [#security](https://hashnode.com/tag/security)
-   [#cryptography](https://hashnode.com/tag/cryptography)
-   [#tutorial](https://hashnode.com/tag/tutorial)
-   [#cli](https://hashnode.com/tag/cli)

## Written by

[Jaden Vo](https://hashnode.com/@jadenvo259)

@jadenvo259

  
[View profile](https://hashnode.com/@jadenvo259)

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
