Random namely ：java.util.Random,
ThreadLocalRandom namely ：java.util.concurrent.ThreadLocalRandom
SecureRandom namely ：java.security.SecureRandom
Q：Random Is it thread safe ？
A：Random It's thread safe , But the performance may be low under multithreading .
Reference resources ：
Q：ThreadLocalRandom Why so soon? ？
A： In fact, this look at the source code to know .. because Random Used a lot of CAS Class ,ThreadLocalRandom It's not used at all .
Q： Why in the case of high intensity requirements , Do not use Random？
A： Especially in the case of generating captcha , Do not use Random, Because it's linearly predictable . I remember a news story about a XX Website , To show its fairness , Open its source code , As a result, the random number predictable vulnerability was attacked . So in the situation of high security requirements , Should be used SecureRandom.
Reference resources ：http://www.inbreak.net/archives/349
Q： Theoretically, random numbers generated by computers are pseudo-random numbers , So how to generate high-intensity random numbers ？
A： Generate high-intensity random numbers , There are two important factors ： Seeds and algorithms . Of course, there are many algorithms , But how to choose the seeds is a key factor . Such as Random, Its seed is System.currentTimeMillis(), So its random numbers are predictable . So how to get an approximately random seed ？ Here's a very unique idea ： Collect all kinds of computer information , Such as keyboard input time ,CPU The clock , Memory usage , Hard disk free space ,IO Time delay , Number of processes , Number of threads and so on , To get an almost random seed . In this case , In addition to the possibility of cracking in theory , In fact, there is no possibility of being cracked . As a matter of fact , Today's high-strength random number generators are implemented in this way .
such as Windows The random number generator under ：
Linux Under the /dev/random：
According to the SecureRandom Of Java doc, Speaking of in class unix Under the system , It could be using /dev/random, To achieve .
Other interesting things ：
The fastest security required generation UUID Methods （ Be careful , The intensity is not high , It's possible to repeat ）：
- new UUID(ThreadLocalRandom.current().nextLong(), ThreadLocalRandom.current().nextLong());
On a website , Forget the source .
Randomly generated functions that generate random numbers ？
Whether a random number generator can be used to generate a series of random code , And then as a new random number generator ？ It seems that strength is transmitted , It doesn't seem to make sense .
[ turn ]Java The random number generator in ：Random,ThreadLocalRandom,SecureRandom More articles about
- Java The random number generator in ：Random,ThreadLocalRandom,SecureRandom
Java The random number generator in :Random,ThreadLocalRandom,SecureRandom In this paper, the Random namely :java.util.Random,ThreadLocalRandom namely : ...
- Java The random number generator in ：Random,ThreadLocalRandom,SecureRandom（ turn ）
In this paper, the Random namely :java.util.Random,ThreadLocalRandom namely :java.util.concurrent.ThreadLocalRandomSecureRandom namely ...
- Java Two methods of generating random numbers in
Java Two methods of generating random numbers in One . utilize random Method to generate Java random number . stay Java It's generated in language Java Random numbers are relatively simple , Because there's a ready-made way to use . stay Math Class ,Java Language provides a ...
- Why do you say Java All random numbers in are pseudo-random numbers ？
What is pseudorandom number ? 1. Pseudo random number is a periodic sequence which seems to be random in nature , That is to say, random with rules . 2. As long as the random number is generated by the deterministic algorithm , That's pseudorandom , It can only be optimized by continuous algorithm , Make your random number closer to random . ( Random this ...
- Java Guess boxing game using random numbers in
Java Guess boxing game using random numbers in , Implementation is very simple , The difficulty lies in the generation of random numbers . First GameJude Class is a class that is used to judge the winning or losing : package testGame; public class GameJudge ...
- java The random number in Random
java In general, there are two kinds of random numbers , One is Math in random() Method , One is Random class . One .Math.random() : Generated immediately 0<x<1 Decimals of example : How to write , Generation random generation ...
- java in random The use of several methods Math.random() and random().
random java Sometimes we need to use random To generate random numbers , Let me give you a brief introduction java in random How to use The first one is :Math.random() public static doub ...
- Java The generation method and principle of random number in
Look up the information about random numbers , It's a special arrangement First of all java There are several ways to generate random numbers in stay j2se We can use Math.random() Method to generate a random number , The resulting random number is 0-1 One between double, We can ...
- Tools section -Java Some of them utils
Below are some of the finishing Java Developed utils, By the way, the editor make complaints about Sina blog bad , So switch to blog Garden One . character string 1. Java in String Conversions with other types String And date objects pu ...
- WPF How to achieve a similar 360 Security guard interface program ？( Shared source code !)
Previous studies Windows Form When programming , I always feel that my interface is ugly , notice 360 Safety guard . Thunderbolt and other software UI The designs are very beautiful , My heart is always looking forward to if I can achieve this UI How good the effect should be !!! Another problem that bothers me is , This ...
- web Big file upload control -jsp-oracle-bug Repair -Xproer.HttpUploader6
explain : Fix delete folder logic error 1. to update up6.js Before updating : After the update : Code : , "RemoveFolder": function (fileSvr) ...
- iOS Of UIWindow Class research
Today I found that if you want to make a beautiful interface effect , We need to study it carefully UIWindow This class . It's not clear why there is such a UIWindow class , It goes with UIView What is the fundamental difference between ? and Android What is more similar in . To do first ...
- NBUT 1010 Magic girl （DP）
 Magic girl The time limit : 1000 ms Memory limit : 65535 K Problem description Some time ago, Xu yuanxuan's great offering and small circle really caught fire . In the black long straight ( Xiaoyan ) Climbing up the stairs to fight against the witch's night , She has a problem and wants to ask for your help . ...
- python Realize single chain table
#! /usr/bin/env python ### ### Linked List python implementation ### ### @reference Data Structures ...
- cxf call c# Of webservice
java call c# Of webservice, Now it has passed the test . And used in the project . Now I'd like to share with you the implementation method and the problems encountered . Detailed source code, such as the following : JaxWsDynamicClientFactory dcf = ...
- PHP Regular expression questions
1.POSIX Regular expressions extend in PHP Which version was abandoned 2. Please write any number that matches , Any white space character , The symbol of any word character ? 3. What is the function that performs a regular expression match ? What are the returned results ? 4. Execute a global regular expression ...
- Yarn A little understanding
Text Open the website http://hadoop.apache.org/docs/r2.6.5/hadoop-yarn/hadoop-yarn-site/YARN.html, Bring me the picture . I use it 2.6.5 ...
- Main stream nosql Database comparison
Currently open source NOSQL The database has ,Redis,Tokyo Cabinet,Cassandra,Voldemort,MongoDB,Dynomite,HBase,CouchDB,Hypertable, Ri ...
- win10 Use... In the environment pyinstaller hold python Code (.py) Package as executable (.exe)
Preface Recently, I wrote a small test program ,python It only takes a hundred lines to write , But when it's packed, there's no C So easy . Here is a record of my difficult " pack " The process . Method 1 :py2exe py2exe It's a classic ...