Is Math.random() cryptographically secure?

后端 未结 5 1065
感动是毒
感动是毒 2020-11-27 16:14

How good are algorithms used in Javascript Math.random() in different browsers? Is it okay to use it for generating salts and one-time passwords?

How ma

5条回答
  •  伪装坚强ぢ
    2020-11-27 16:52

    Math.random() is not cryptographically secure. Also Veracode will point this occurrence with

    CWE-331 (Insufficient Entropy)

    We could make use of SecureRandom to implement similar functionality.

    new SecureRandom().nextDouble();
    

提交回复
热议问题