adsense728x90


java math random platform independence


random seed가 같을 때 같은 값이 생성되나보다.
다른 platform에서 generate하더라도.



If two instances of Random are created with the same seed, and the same sequence of method calls is made for each, they will generate and return identical sequences of numbers. In order to guarantee this property, particular algorithms are specified for the class Random. Java implementations must use all the algorithms shown here for the class Random, for the sake of absolute portability of Java code. However, subclasses of class Random are permitted to use other algorithms, so long as they adhere to the general contracts for all the methods.


SecureRandom은 platform dependent한 지도 모르겠다.


문서를 읽어보면 그렇지 않을 것 같기는 한뎅.

Like other algorithm-based classes in Java Security, SecureRandom provides implementation-independent algorithms, whereby a caller (application code) requests a particular PRNG algorithm and is handed back a SecureRandom object for that algorithm. It is also possible, if desired, to request a particular algorithm from a particular provider. See the getInstance methods.

http://docs.oracle.com/javase/1.4.2/docs/api/java/security/SecureRandom.html


algorithm을 지정하면 deterministic한 pseudo random sequence를 얻을 수 있는 것 같다.

지정을 제대로 안하면 platform에 따라 다르다. unux 계열에서는 
/dev/random
/dev/urandom 
같은 데서 random 값을 가져온다.








덧글

댓글 입력 영역