Android Random Byte Array randomStr(int length)

Here you can find the source of randomStr(int length)

Description

random Str

License

Open Source License

Declaration

public static String randomStr(int length) 

Method Source Code

//package com.java2s;

import java.util.Random;

public class Main {

    public static String randomStr(int length) {

        String hash = "";
        String charStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz";
        char chars[] = charStr.toCharArray();
        int max = chars.length;
        Random random = new Random();
        for (int i = 0; i < length; i++) {
            hash += chars[Math.abs(random.nextInt()) % max];
        }//from w ww.java2s.  c  om

        return hash;
    }
}

Related

  1. fillRandomBytes(byte[] bytes)
  2. getRandomByte()
  3. getRandomByteArrays(int arrSize)
  4. randomInt(int min, int max)
  5. randomStr(int length)
  6. generateSalt()
  7. generateSalt()
  8. getRandomBytes(final int size)