Skip to main content
Fixed the indentation, etc.
Source Link
Peter Mortensen
  • 31.4k
  • 22
  • 110
  • 134
public static String generateSessionKey(int length){  String alphabet =  new String("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"); // 9    int n = alphabet.length(); // 10  String result = new String();   Random r = new Random(); // 11  for (int i=0; i<length; i++) // 12   result = result + alphabet.charAt(r.nextInt(n)); //13  return result; } 
public static String generateSessionKey(int length){ String alphabet =  new String("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"); //9 int n = alphabet.length(); //10 String result = new String();  Random r = new Random(); //11 for (int i=0; i<length; i++) //12 result = result + alphabet.charAt(r.nextInt(n)); //13 return result; } 
public static String generateSessionKey(int length){  String alphabet = new String("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"); // 9    int n = alphabet.length(); // 10  String result = new String();  Random r = new Random(); // 11  for (int i=0; i<length; i++) // 12   result = result + alphabet.charAt(r.nextInt(n)); //13  return result; } 
Post Made Community Wiki by neuhaus
added 14 characters in body
Source Link
Vikdor
  • 24.2k
  • 10
  • 66
  • 86
public static String generateSessionKey(int length){ String alphabet =  new String("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"); //9 int n = alphabet.length(); //10 String result = new String(); Random r = new Random(); //11 for (int i=0; i<length; i++) //12 result = result + alphabet.charAt(r.nextInt(n)); //13 return result; } 
public static String generateSessionKey(int length){ String alphabet = new String("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"); //9 int n = alphabet.length(); //10 String result = new String(); Random r = new Random(); //11 for (int i=0; i<length; i++) //12 result = result + alphabet.charAt(r.nextInt(n)); //13 return result; } 
public static String generateSessionKey(int length){ String alphabet =  new String("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"); //9 int n = alphabet.length(); //10 String result = new String(); Random r = new Random(); //11 for (int i=0; i<length; i++) //12 result = result + alphabet.charAt(r.nextInt(n)); //13 return result; } 
added 4 characters in body
Source Link
McGarnagle
  • 103k
  • 31
  • 235
  • 264

public static String generateSessionKey(int length){ String alphabet = new String("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"); //9 int n = alphabet.length(); //10

public static String generateSessionKey(int length){ String alphabet = new String("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"); //9 int n = alphabet.length(); //10 String result = new String(); Random r = new Random(); //11 for (int i=0; i<length; i++) //12 result = result + alphabet.charAt(r.nextInt(n)); //13 return result; } 

public static String generateSessionKey(int length){ String alphabet = new String("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"); //9 int n = alphabet.length(); //10

String result = new String(); Random r = new Random(); //11 for (int i=0; i<length; i++) //12 result = result + alphabet.charAt(r.nextInt(n)); //13 return result; } 
public static String generateSessionKey(int length){ String alphabet = new String("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"); //9 int n = alphabet.length(); //10 String result = new String(); Random r = new Random(); //11 for (int i=0; i<length; i++) //12 result = result + alphabet.charAt(r.nextInt(n)); //13 return result; } 
Source Link
rina
  • 21
  • 1
  • 2
Loading