【发布时间】:2021-07-21 15:29:42
【问题描述】:
我需要将 Java 中的一个函数翻译成 Node JS
public byte[] GetId() throws NoSuchAlgorithmException {
byte[] byArray = new byte[4];
byte[] byArray2 = new byte[8];
SecureRandom secureRandom = SecureRandom.getInstance("SHA1PRNG");
secureRandom.nextBytes(byArray);
secureRandom.nextBytes(byArray2);
return byArray2;
}
那么secureRandom.getInstance 和nextBytes 与Javascript 的等价性是什么?
我需要使用加密库吗?喜欢:
crypto.randomBytes(8)
?
【问题讨论】:
标签: javascript java node.js cryptography secure-random