Skip to content

node module intended to be a clone of python's random module with a focus on cryptographic security and speed

License

Notifications You must be signed in to change notification settings

kalirosenkreuz/Positivity

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Positivity

Positivity is a Node.js module intended to both (sort of) replicate Python's Random module and implement ISAAC for cryptographic security and speed. Currently a work in progress, and should not be used in production.

Why use Positivity?

Security

Positivity implements the ISAAC pseudo-random number generator, which is cryptographically secure. Seeds are pulled from system-specific sources; /dev/urandom on UNIX-based systems and CryptGenRandom on windows.

Speed

When tested with Benchmark.js, Positivity has an advantage of several hundred thousand more operations per second over the crypto module.

Installation

Build, require, and then positivity.Initialize()

API

All methods (except for Initialize) have an optional callback parameter. If this parameter is not included, methods are not guaranteed to be asynchronous.

positivity.Initialize()

Initializes the random number generator. Should be called before any functions are used.

positivity.getInt()

Returns a random integer between -2147483647 and 2147483647.

positivity.getFloat()

Returns a random floating point number between -1 and 1.

positivity.getIntInRange(min, max)

Returns a random integer between min and max.

positivity.getFloatInRange(min, max)

Returns a random floating point number between min and max.

positivity.Choice(arr)

Returns a random element from the array arr.

positivity.Choices(arr, size)

Returns size random samples from array arr.

positivity.Shuffle(arr)

Returns arr after being shuffled.

positivity.Bytes(length)

Returns a buffer with length random bytes.

About

node module intended to be a clone of python's random module with a focus on cryptographic security and speed

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published