Skip to content

Instantly share code, notes, and snippets.

@ObjectBoxPC
Last active August 2, 2025 19:28
Show Gist options
  • Select an option

  • Save ObjectBoxPC/16a32f6ae31fcc0de7d5df52e7618faf to your computer and use it in GitHub Desktop.

Select an option

Save ObjectBoxPC/16a32f6ae31fcc0de7d5df52e7618faf to your computer and use it in GitHub Desktop.
Quickly generate random numeric PINs
#!/usr/bin/env python3
# Usage: ./makepin.py [number of digits, default 4]
import secrets
import sys
digit_count = int(sys.argv[1]) if len(sys.argv) >= 2 else 4
print("".join(str(secrets.randbelow(10)) for _ in range(digit_count)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment