Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
@szydlovski/alea
Advanced tools
Seedable random, an implementation of Johannes Baagøe's Alea algorithm. Mostly a refactored copy paste with the addition of some convenience methods.
npm install @szydlovski/alea
const Alea = require('@szydlovski/alea');
// will always produce the same numbers for the same seed
new Alea('seed1').next() // 0.061422935919836164
new Alea('seed1').next() // 0.061422935919836164
new Alea('seed2').next() // 0.37036016467027366
const generator = new Alea('seed');
for (let i = 0; i++ < 100;) {
generator.next();
}
// two ways to clone an existing generator
const clone1 = new Alea().importState(generator.exportState());
const clone2 = generator.clone();
generator.next(); // 0.6304205257911235
clone1.next(); // 0.6304205257911235
clone2.next(); // 0.6304205257911235
Creates a new instance, optionally using a seed
, otherwise the current date is used. The seed will be stringified using toString
.
Generates and returns the next random number between 0
and 1
.
Alias of Alea.next
.
Returns a copy of the instance's internal state, in the form of an array containing four numbers.
Imports a given state into the instance. The state should be an array containing four numbers, like the array returned by Alea.exportState
. Returns the instance, allowing for chained calls like:
const generator = new Alea().importState(state);
Clones the instance. This is the equivalent of:
const clone = new Alea().importState(instance.exportState());
Copyright (C) 2010 by Johannes Baagøe baagoe@baagoe.org
Copyright (C) 2020 by Kamil Szydlowski kamil.szydlovski@gmail.com
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
FAQs
seedable random, an implementation of Johannes Baagøe's Alea
We found that @szydlovski/alea demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.