Giter Club home page Giter Club logo

node-randomstring's People

Contributors

davidguttman avatar dchest avatar eliaskg avatar hayzamjs avatar iuriiiii avatar micromaomao avatar mindsers avatar pcarranzav avatar pdehaan avatar yukha-dw avatar zeke avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

node-randomstring's Issues

Option for case-insensitive char sets

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).

Getting lots of duplicates

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?

Fails to generate strings in Electron

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.

ReactJS app not responsive when using randomstring.generate()

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.

Hangs Chrome

For some reason this hangs Chrome indefinitely. Anyone else experiencing this?

Charset type is a string to string of array

Screenshot 2024-02-16 111539
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.

async version?

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.

Random String with Prefix

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!

characters are not generated uniformly

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.