4 Replies Latest reply: Feb 23, 2010 7:01 AM by 800268 RSS

    understandin security random number generator

    807580
      Hi all,

      I was willing to generate a secure random number using the SecureRandom Class rather than random. Now I am getting the concept here as which one is the random number.
      The code I am using from java site is below:
      import java.security.SecureRandom;
      
      class Test{
      public static void main(String[] args){
      
      
            SecureRandom random = new SecureRandom();
            byte bytes[] = new byte[20];
            random.nextBytes(bytes);
      
              for ( int i=0;i <bytes.length; i++)
                      System.out.println(bytes);
      }
      }
      Now it prints a series of numbers like 
      -2812759-358768-7118-128-10511436-106-103-8-19-99-961999
      Now is the whole thing a random number? why there is a dash (-) between the numbers?
      All I need is just a random number using securerandom class.
      
      Thanks in advance.