klughammer / node-randomstring Goto Github PK
View Code? Open in Web Editor NEWA node.js module for generating random strings
License: MIT License
A node.js module for generating random strings
License: MIT License
Hi! Would it be possible to have some short-hand charset options - or a separate option - for generating all upper or all lower random strings?
Ideally, my current use-case I want 0-9 plus A-Z (but not a-z).
node-randomstring/lib/randomstring.js
Lines 59 to 62 in f504e85
Previously reported and fixed elsewhere:
If I generate a number of random strings in close enough proximity to each other, they're all turning out the same. After reading through your code, this seems like an issue inherent to crypto
. Any ideas on how to, e.g., seed the crypto.randombytes
function with a Date.now
timestamp?
Unsure if it is due to it being Electron or running webpack-dev-server, but the catch block here runs indefinitely:
function safeRandomBytes(length) {
while (true) {
try {
return randomBytes(length);
} catch(e) {
continue;
}
}
}
The fact that randombytes operates differently in Node and in the browser seems like it could be the underlying cause.
Hi,
I need random strings with alphanumberic and special characters (._-,~) as characters set
Hihi!
I am using your package in my ReactJS project and I realised when randomstring.generate() is called, somehow the site just hangs and becomes unresponsive. Importing the package had no issues, only when running it. Any idea why?
It can be replicated by creating a new react app, installing randomstring dependency and calling randomstring.generate() anywhere.
hard to find you because your git url is wrong on npmjs.org
return require('crypto').randomBytes(length).toString('hex');
For some reason this hangs Chrome indefinitely. Anyone else experiencing this?
Unable to use charset: ['numeric', '!']
with typescript as the charset type is written as string. It's properly working in javascript but unable to use it in typescript as the type should be a string[]
.
randomstring\index.d.ts: 9 should be a string[] instead of string so typescript users can use it.
Is there an option for an async version? If I understand correctly, using randomBytes()
synchronously results in blocking on some platforms and could reduce performance for a busy server.
Feature request:
Generate gory gory unicode.
Prior art: https://www.npmjs.com/package/random-unicode.
Would it be hard to add special characters like !@#$%^
to the charset?
#FeatureRequest
Is there a solution when using a random string that has a prefix for the generated string?
For example in case I want to generate 16 random characters but they all start with "AR", is there any solution for me?
Thank you!
version: 1.2.2
0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz
That second T should be Y.
numbers 0-7 are generated more often then other characters. Because the number of characters is 62. The random number from generator is 0-255. 256 is not multiple of 62.
You should replace
var index = bf.readUInt8(i) % chars.length;
with something like this:
while((random = bf.readUInt8(i++))>=248); // 248 = 4*62
index = random % 62;
to throw away the nonuniform remainder
A 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.