Sitemap
Press enter or click to view image in full size

Member-only story

Random Values — In the Browser

2 min readFeb 2, 2025

--

At the core of cryptography is the generation of random numbers. These can be true random numbers — such as those generated by the noise in resistors — or pseudo-random numbers. The generation of true random numbers can be expensive, and so most systems use pseudo-random generation, where we generate a seed value which is fairly random to initialise the random sequence.

The Web Cryptography integration provides a strong random number generation named Crypto.getRandomValues(). This method fills an Uint32 array with random values and is a pseudo-random number generator (PRNG) seeded with a value with a defined level of entropy. The method uses user agents to provide the best entropy possible and is seeded from a platform-specified random number source. For Linux systems, this is from /dev/urandom.

The following is the code [here]:

<style>
.dropdown {
font-size: 16px;
border: 2px solid grey;
width: 100%;
border-left: 12px solid green;
border-radius: 5px;
padding: 14px;
}
pre {
font-size: 16px;
border: 2px solid grey;
width: 100%;
border-left: 12px solid green;
border-radius: 5px;
padding: 14px;
}textarea {
font-size: 20px;
border: 2px solid grey;
width: 100%;
border-radius: 5px;
padding: 14px…

--

--

Prof Bill Buchanan OBE FRSE
Prof Bill Buchanan OBE FRSE

Written by Prof Bill Buchanan OBE FRSE

Professor of Cryptography. Serial innovator. Believer in fairness, justice & freedom. Based in Edinburgh. Old World Breaker. New World Creator. Building trust.