import java.security.SecureRandom; .. Random ranGen = new SecureRandom(); byte[] aesKey = new byte[8]; // 8 bytes = 64 bits ranGen.nextBytes(aesKey);
Similarly, Can somebody please tell me how to generate the secure random number in scala and convert it into alpha-numeric format?Thanks in advance,Jitendra
--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-user+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "scala-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-user+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
On Wed, Jun 25, 2014 at 11:14:35AM -0700, jitendra shelar wrote:Spire [1] has a wrapper around Java's SecureRandom class [2] [3]:
> Similarly, Can somebody please tell me how to generate the secure
> random number in scala and convert it into alpha-numeric format?
import spire.random.mutable.SecureJava
SecureJava().generateBytes(16).map("%02x" format _).mkString
-- Erik
[1] https://github.com/non/spire
[2] You may want to seed the RNG yourself. Also, this is the code
you'd use with Spire's most recent release. In the master branch the
class is found in spire.random.rng instead.