16 lines
416 B
JavaScript
16 lines
416 B
JavaScript
/**
|
|
* @ Author: yanxbm
|
|
* @ Create Time: 2021-02-20 15:42:46
|
|
* @ Create by: yanxbm
|
|
* @ Modified by: chendch
|
|
* @ Modified time: 2021-02-24 16:46:04
|
|
* @ Description: 安全的PRNG
|
|
*/
|
|
|
|
const getRandom = () => {
|
|
if(!window.crypto && (window).msCrypto){
|
|
(window).crypto = (window).msCrypto;
|
|
}
|
|
return window.crypto.getRandomValues(new Uint32Array(1))[0] / 4294967296;
|
|
}
|
|
export default getRandom; |