puyuan / py-nanoid Goto Github PK
View Code? Open in Web Editor NEWPython Nanoid
License: MIT License
Python Nanoid
License: MIT License
Is this an exact port of the JS nanoid project? If not, what differs?
First: Thx for providing this python implementation!
In one of my projects we are migrating applications from e.g. kubernetes java pods to services comprised of AWS lambdas. Right now we are using a stateful id generator (based on twitter snowflake, https://developer.twitter.com/en/docs/twitter-ids).
Nanoid (with it's javascript and python implementation) seems like a perfect match for this new use case. My only concern/question is, if by using nanoid in AWS lambda we are running into problems with nanoid not having enough entropy to create secure ids.
The readme says:
Nano ID uses the crypto module in Node.js
For the node.js AWS lambda environment we should be fine (Andrey confirmed that: ai/nanoid#289 (comment)).
I'm a little bit unsure about the python implementation. Do you have experiences / insights to share?
Thx for your help!
I don't know why nanoid make a string included dot(.)
for example 593uu.uC387.y
Hello, as a prerequisite, I want to tell you that this post falls in a category 'I wonder, what if...'.
So, I just want to leave you thinking about making this package even smaller and in one file.
Reasons are:
Drawbacks:
secrets
package is not available in Python 2 πIn the end, this what makes Python really stand out: short but clear expressions, which are easy to read and write.
from functools import reduce
from operator import concat
import random
import secrets
alphabet_std = '_-0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
default_size = 21
def non_secure_generate(alphabet=alphabet_std, size=default_size):
return reduce(concat, (random.choice(alphabet) for _ in range(size)))
def generate(alphabet=alphabet_std, size=default_size):
return reduce(concat, (secrets.choice(alphabet) for _ in range(size)))
print(generate(alphabet="12345a", size=3))
Traceback (most recent call last):
File "E:/nanoid.py", line 33, in
print(generate(alphabet="12345a", size=3))
File "E:/nanoid.py", line 26, in generate
if alphabet[byte]:
IndexError: string index out of range
Process finished with exit code 1
All distributions of this software must include a copy of the license, or else they cannot be redistributed.
This is the only implementation of nanoid in python that I can find, but the last commit was over two years ago.
I was wondering if this project is totally abandoned or is still being maintained. Thanks.
Linux distros run these as part of their package build process.
Hello! I also recreated new version of Nano ID on Python and would like to know, whether it is possible to merge our projects now as I see you are being active on updating the project too.
Why do I want this?
py-nanoid is hosted on PyPi with the name of nanoid. In order not to create confusion among users, it is better to have more powerful single package without duplicates on pip, such as nanoid2 (which is allegedly has been taken myself) and other nonsense.
Would love to hear from you good news!
Letβs update the library to be compatible with the latest Nano ID 2.0:
~
to -
in default alphabetnon-secure
fast generatorI am sorry for delaying the release, but I have decided to go for porting all tests from original nanoid. Therefore, project structure is something to be concerned of. In order not to waste your time, I will put everything out linted and tested later.
Suggestion:
nanoid-dictionary
repository seems to be brokenA declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.