Random numbers generation in java and VB

I have to duplicate a program written in VB to java.The problem Iam facing is that random numbers are used for encryting in VB.The random numbers that Iam generating in my java code are different from those being generated by my VB program.Are the algorithms for random number different in VB and java?Is there some other way to generate random numbers in java other then using Random class

Thanks in advance

amit

[453 byte] By [amitsharma97] at [2007-9-26 4:35:49]
# 1

What did you expect? You are asking for *random* numbers, not numbers given by this or that particular pseudo-random number generator. If you want the same "random" numbers you'll need to make a function/method of your own and implement it in both VB and Java.

> Is there some other way to generate random numbers

> in java other then using Random class

Yes, Math.random()

jsalonen at 2007-6-29 17:53:15 > top of Java-index,Archived Forums,Java Programming...
# 2
Thanks does psuedo random number generator in VB and in java returns the same value if we pass the same seed value?thanksamit
amitsharma97 at 2007-6-29 17:53:15 > top of Java-index,Archived Forums,Java Programming...
# 3
You dont know what number random will return - because it is random.//Anders ;-D
anders.hedstrom at 2007-6-29 17:53:15 > top of Java-index,Archived Forums,Java Programming...
# 4

Depends on the implementation. A RNG with the same seed will always generate the same sequence, regardless of the language, just like 2+2 = 4 in every language. You just need to get an implementation of the same RNG in both languages.

It's probably easier to port the Random class to VB since we have the source for it...

jsalonen at 2007-6-29 17:53:15 > top of Java-index,Archived Forums,Java Programming...
# 5
> You dont know what number random will return - because it is random.Then how does the method itself end up with the value it'll return?That's why they are called *pseudo* random number generators.
jsalonen at 2007-6-29 17:53:15 > top of Java-index,Archived Forums,Java Programming...
# 6
You could implement your own random number generator to get better random numbers http://scicomp.ewha.ac.kr/gams/cgi-bin/gams-serve/class/L6a21.html
StreichertF at 2007-6-29 17:53:15 > top of Java-index,Archived Forums,Java Programming...