September 2018
Intermediate to advanced
764 pages
20h 6m
English
JavaScript's Math.random() does not provide an option to provide a seed, but there are libraries out there that implement a PRNG in JavaScript. Two of the most popular ones are seedrandom and random-seed. Out of the two, the random-seed package provides a string(count) method that'll generate a random string instead of a random number; because of this convenience, we will use the random-seed package to generate our fake salt.
First, let's install it:
$ yarn add random-seed
Now, create a new file at utils/generate-fake-salt.js and define a new generateFakeSalt function that will output a fake salt based on the email of the user:
import randomseed from 'random-seed';function generateFakeSalt(seed) { const salt = randomseed // ...Read now
Unlock full access