久久久久久久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)
主站蜘蛛池模板: 国产福利视频导航 | 国产日韩欧美精品一区二区 | 日韩一区二区三区av | 伊人无码高清 | 亚洲欧美在线视频 | 国产精品a久久久久 | 九九热免费在线观看 | 中文字幕精品一区久久久久 | 成人夜晚看av | 欧美一区二区成人 | 精品视频在线免费观看 | 国产91在线 | 亚洲 | 日韩有码在线观看 | 日韩欧美精品一区 | 日本中文字幕一区 | 午夜电影在线播放 | 日韩国产精品一区二区三区 | 精品入口麻豆88视频 | www性色 | 伊人春色在线观看 | 国产乱码精品一区二三赶尸艳谈 | 久久久国产一区二区 | 黄色免费网址大全 | 天天操天天天干 | 欧美一级在线视频 | 一级a性色生活片久久毛片 午夜精品在线观看 | 日本天堂视频在线观看 | 日韩精品1区2区 | 国产特级毛片 | 罗宾被扒开腿做同人网站 | 日韩国产一区二区三区 | 欧美日韩在线观看视频网站 | 国产清纯白嫩初高生视频在线观看 | 中文字幕日韩一区 | 久久亚洲一区二区三 | 天天天天操 | 日韩人体视频 | 成人高清在线视频 | 91久久 | 国产一二三区电影 | 成人精品在线观看 |