Javascript 中是否有加密安全伪随机数生成器 (CSPRNG)?
我知道我可以使用生成伪随机数
Math.random();
function getRandomInt(max) {
return Math.floor(Math.random() * Math.floor(max));
}
Run Code Online (Sandbox Code Playgroud)
在Python中我会使用secrets()而不是random().
import secrets alphabet = string.ascii_letters + string.digits password = ''.join(secrets.choice(alphabet) for i in range(8))
Run Code Online (Sandbox Code Playgroud)
在 Go 中我会使用crypto.randpackage 而不是math/randpackage。
package main
import (
"bytes"
"crypto/rand"
"fmt"
)
func main() {
c := 10
b := make([]byte, c)
_, err := rand.Read(b)
if err != nil {
fmt.Println("error:", err)
return
}
fmt.Println(bytes.Equal(b, make([]byte, c)))
}
Run Code Online (Sandbox Code Playgroud)
javascript 中有等价的吗?
是否可以设置默认工具提示的样式?这是 展示默认工具提示的JSFiddle。
<form>
<input type="text" placeholder="Submit without entering value" required>
<input type="submit">
</form>
Run Code Online (Sandbox Code Playgroud)