fortify测试前端js 不能使用Math.random()的问题

编程入门 行业动态 更新时间:2024-10-13 18:23:23

fortify<a href=https://www.elefans.com/category/jswz/34/1771117.html style=测试前端js 不能使用Math.random()的问题"/>

fortify测试前端js 不能使用Math.random()的问题

fortify扫描前端源代码,报Insecure Randomness错误,如何解决呢?

说是Math.random()有漏洞,不知道是个什么鬼,但是不解决就过不去。测试那边也是死板的要命,没办法,只能自己写一个随机数函数了。

在网上查了一下,以下代码有效:

<html>
<head>
<script>
    
    
    rnd.today=new Date();
    rnd.seed=rnd.today.getTime();
    function rnd() {
     rnd.seed = (rnd.seed*9301+49297) % 233280;
     return rnd.seed/(233280.0);
    };
    function rand(number) {
     return Math.ceil(rnd()*number);
    };
    function doooo(){
        alert("1111");
        alert(rnd());
        
        var item=rand(100);
        alert(item);
    }
</script>
</head>
<body>
<input value="按钮" type="button" οnclick="doooo()"/&g

更多推荐

fortify测试前端js 不能使用Math.random()的问题

本文发布于:2023-12-03 11:30:33,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1654863.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:测试   fortify   js   random   Math

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!