久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

SecureRandom:初始化一次還是每次都需要?

SecureRandom: init once or every time it is needed?(SecureRandom:初始化一次還是每次都需要?)
本文介紹了SecureRandom:初始化一次還是每次都需要?的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

問題描述

我們的團(tuán)隊(duì)正在使用 SecureRandom 生成密鑰對(duì)列表(SecureRandom 被傳遞給 KeyPairGenerator).我們無(wú)法就使用以下兩個(gè)選項(xiàng)中的哪一個(gè)達(dá)成一致:

Our team is using a SecureRandom to generate a list of key pairs (the SecureRandom is passed to a KeyPairGenerator). We cannot agree on which of the following two options to use:

  1. 每次我們需要生成密鑰對(duì)時(shí)都創(chuàng)建一個(gè)新實(shí)例

  1. Create a new instance every time we need to generate a key pair

初始化一個(gè)靜態(tài)實(shí)例并將其用于所有密鑰對(duì)

Initialize a static instance and use it for all key pairs

哪種方法通常更好,為什么?

添加:我的直覺是第二種選擇更安全.但我唯一的論點(diǎn)是基于偽隨機(jī)性源自當(dāng)前時(shí)間戳的假設(shè)的理論攻擊:有人可能會(huì)看到密鑰對(duì)的創(chuàng)建時(shí)間,猜測(cè)周圍時(shí)間間隔內(nèi)的時(shí)間戳,計(jì)算可能的偽隨機(jī)序列,并獲得關(guān)鍵材料.

ADDED: My gut feeling is that the second option is more secure. But my only argument is a theoretical attack based on the assumption that the pseudorandomness is derived from the current timestamp: someone may see the creation time of the key pair, guess timestamps in the surrounding time interval, compute the possible pseudorandom sequences, and obtain the key material.

補(bǔ)充:我關(guān)于基于時(shí)間戳的確定性的假設(shè)是錯(cuò)誤的.這就是 Random 和 SecureRandom 之間的區(qū)別.所以,看起來(lái)答案是:就安全性而言,這并不重要.

ADDED: My assumption about determinism based on a timestamp was wrong. That's the difference between Random and SecureRandom. So, it looks like the answer is: in terms of security it doesn't really matter.

推薦答案

java.util.Random 類不同,java.security.SecureRandom 類必須產(chǎn)生非- 每次調(diào)用的確定性輸出.

Unlike the java.util.Random class, the java.security.SecureRandom class must produce non-deterministic output on each call.

這意味著,在 java.util.Random 的情況下,如果您每次需要一個(gè)新的隨機(jī)數(shù)時(shí)都使用相同的種子重新創(chuàng)建一個(gè)實(shí)例,那么您基本上會(huì)得到 same 每次結(jié)果.但是,SecureRandom 保證不會(huì)這樣做 - 因此,每次創(chuàng)建單個(gè)實(shí)例或創(chuàng)建一個(gè)新實(shí)例 not 不會(huì)影響它生成的隨機(jī)字節(jié)的隨機(jī)性.

What that means is, in case of java.util.Random, if you were to recreate an instance with the same seed each time you needed a new random number, you would essentially get the same result every time. However, SecureRandom is guaranteed to NOT do that - so, creating a single instance or creating a new one each time does not affect the randomness of the random bytes it generates.

那么,從正常的良好編碼實(shí)踐的角度來(lái)看,為什么要?jiǎng)?chuàng)建太多實(shí)例呢?

So, from just normal good coding practices view point, why create too many instances when one will do?

這篇關(guān)于SecureRandom:初始化一次還是每次都需要?的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

Java Remove Duplicates from an Array?(Java從數(shù)組中刪除重復(fù)項(xiàng)?)
How to fix Invocation failed Unexpected Response from Server: Unauthorized in Android studio(如何修復(fù)調(diào)用失敗來(lái)自服務(wù)器的意外響應(yīng):在 Android 工作室中未經(jīng)授權(quán))
AES encryption, got extra trash characters in decrypted file(AES 加密,解密文件中有多余的垃圾字符)
AES Error: Given final block not properly padded(AES 錯(cuò)誤:給定的最終塊未正確填充)
Detecting incorrect key using AES/GCM in JAVA(在 JAVA 中使用 AES/GCM 檢測(cè)不正確的密鑰)
AES-256-CBC in Java(Java 中的 AES-256-CBC)
主站蜘蛛池模板: 毛片视频免费 | 精品一区二区在线观看 | 欧美日韩亚洲国产 | 欧美一二三四成人免费视频 | 超碰97人人人人人蜜桃 | 亚洲国产免费 | 国内自拍第一页 | 精区3d动漫一品二品精区 | 久久精品国产v日韩v亚洲 | 三级成人片 | 国产精品日韩一区二区 | 成人免费福利视频 | 久久久精品一区 | 欧美精品成人 | 狠狠色综合久久婷婷 | 午夜影院在线免费观看视频 | 国产剧情一区 | 亚洲精品日韩综合观看成人91 | 欧美色999 | 欧洲亚洲一区二区三区 | 欧美激情精品久久久久久变态 | 国产中文 | 日韩中文字幕在线观看 | 中文字幕在线一区二区三区 | 在线观看国产三级 | 毛片网站免费观看 | 久久国产视频网站 | av激情影院 | 亚洲狠狠爱 | 国产成人99久久亚洲综合精品 | 日韩一级电影免费观看 | 日本精品一区二区三区四区 | 五月婷六月丁香 | 成人一区二区在线 | 精品日韩一区 | 91精品国产一区二区三区蜜臀 | 福利视频二区 | 国产日韩免费观看 | 国产精品久久久久久妇女6080 | 99久久精品免费看国产四区 | 午夜影院操 |