You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

14 lines
322 B

import crypto from 'crypto';
export function crypto_random32() {
const arr = new Uint8Array(4);
const dataview = new DataView(arr.buffer);
crypto.getRandomValues(arr);
return dataview.getUint32(0);
}
export function round_to_pow2(value, multiple) {
return (value + multiple - 1) & -multiple;
}