Comments (1)
@jpgoldberg Here's a stab at resolving the bias:
from os import urandom
import string
def generate_password(length=50):
rand_max = 256
rand_excess = (rand_max + 1) % length
rand_limit = rand_max - rand_excess
chars = string.uppercase + string.lowercase + string.punctuation + string.letters
def next_index():
while True:
x = ord(urandom(1))
if x <= rand_limit:
return x % length
return ''.join(chars[next_index()] for _ in range(length))
If I've implemented this correctly, the above should make sure the actual len(chars)
used to derive the password is a divisor of 256.
from pick.
Related Issues (20)
- Add Github "topics" HOT 3
- New release, please :) HOT 8
- `import` command HOT 5
- Document! HOT 7
- Add support for Diceware passwords HOT 1
- How do you use pick on phone? HOT 1
- Syncing pick safe with itself errors out: "panic: assignment to entry in nil map" HOT 1
- TravisCI tests fail on PRs HOT 2
- Installation with `go get` leads to version parsing error when loading safe HOT 4
- Location of pick.safe file HOT 4
- Implement locking in s3 backend
- Install script HOT 4
- Build problem on OpenBSD HOT 18
- v1.0 release HOT 4
- Safe defaults to openpgp HOT 2
- --safe switch fails to pickup safe file from supplied location HOT 2
- Generate configs
- XDG Base Directory Support
- transfer credentials to another laptop
- Transition to read-only
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pick.