0.0.1 • Published 12 months ago

trng2 v0.0.1

Weekly downloads
-
License
GPL-3.0
Repository
github
Last release
12 months ago

trng2

trng2 is a modified version of the original trng package available at https://www.npmjs.com/package/trng. This Node.js module generates random numbers with a high degree of randomness, suitable for use in various applications, including simulations, games, and cryptographic operations.

Modifications

The original trng package generates a hexadecimal string representing a random number. In contrast, trng2 generates a floating-point number in the range [0, 1), making it more convenient for use in certain applications like genetic algorithms.

The modification maintains the high degree of randomness from the original trng package. It uses multiple sources of entropy, including the current timestamp, process-specific entropy (based on the process's high-resolution real-time clock and process ID), and cryptographically strong random values generated by the crypto.randomBytes function. The generated random number still has 64 bits of randomness, just like the original hexadecimal string.

Usage

Here's a simple example of how to use the trng2 module:

const trng2 = require('trng2');

trng2.generate((randomNumber) => {
  console.log(`Generated random number: ${randomNumber}`);
});

In this example, trng2.generate generates a random floating-point number between 0 and 1, and then calls the provided callback function with this number.

Installation

You can install trng2 using npm:

npm install trng2

Please note that you need to replace 'trng2' with the actual path to the trng2 module in your project.

Contributing

Feel free to dive in! Open an issue or submit PRs.

License

GPL-3.0 © Harshad Joshi