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

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

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

問題描述

我們的團隊正在使用 SecureRandom 生成密鑰對列表(SecureRandom 被傳遞給 KeyPairGenerator).我們無法就使用以下兩個選項中的哪一個達成一致:

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. 每次我們需要生成密鑰對時都創建一個新實例

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

初始化一個靜態實例并將其用于所有密鑰對

Initialize a static instance and use it for all key pairs

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

添加:我的直覺是第二種選擇更安全.但我唯一的論點是基于偽隨機性源自當前時間戳的假設的理論攻擊:有人可能會看到密鑰對的創建時間,猜測周圍時間間隔內的時間戳,計算可能的偽隨機序列,并獲得關鍵材料.

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.

補充:我關于基于時間戳的確定性的假設是錯誤的.這就是 Random 和 SecureRandom 之間的區別.所以,看起來答案是:就安全性而言,這并不重要.

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 類必須產生非- 每次調用的確定性輸出.

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

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

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.

那么,從正常的良好編碼實踐的角度來看,為什么要創建太多實例呢?

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

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

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

相關文檔推薦

Java Remove Duplicates from an Array?(Java從數組中刪除重復項?)
How to fix Invocation failed Unexpected Response from Server: Unauthorized in Android studio(如何修復調用失敗來自服務器的意外響應:在 Android 工作室中未經授權)
AES encryption, got extra trash characters in decrypted file(AES 加密,解密文件中有多余的垃圾字符)
AES Error: Given final block not properly padded(AES 錯誤:給定的最終塊未正確填充)
Detecting incorrect key using AES/GCM in JAVA(在 JAVA 中使用 AES/GCM 檢測不正確的密鑰)
AES-256-CBC in Java(Java 中的 AES-256-CBC)
主站蜘蛛池模板: 日日操日日干 | 久久狠狠干 | 91一级片 | 日本中文字幕网站 | 国产精品乱 | 亚洲成人国产 | 久久精品欧美一区二区三区不卡 | 伊人精品久久 | 天天摸天天干 | av网站观看 | 午夜免费小视频 | 国产超碰人人模人人爽人人添 | 国产精品美女久久久久久久久 | 日韩一区二区三区在线播放 | a一级黄色片 | 日韩在线视频观看 | 国产视频一区二区在线观看 | av在线资源 | 亚洲精品色 | 黄色一级大片在线免费看国产一 | 亚洲视频一区二区三区四区 | 免费成人在线观看 | 午夜影院在线免费观看 | 日韩视频在线免费观看 | 97免费在线 | 日韩欧美黄色 | 青青草免费在线观看视频 | 免费av一区二区 | 欧美日韩国 | 免费国产精品视频 | 人成在线 | 成人激情在线观看 | 亚洲国产成人在线 | 成年人视频在线播放 | 国产一区二区免费看 | 亚洲国产精品久久久久久久 | 亚洲第一视频网站 | 国产精品久久久999 成人在线国产 | 色影视| 日韩欧美在线视频 | 国产视频成人 |