Java Password Generate generateStringsEntries(int cnt)

Here you can find the source of generateStringsEntries(int cnt)

Description

generate Strings Entries

License

Open Source License

Declaration

public static Map<String, String> generateStringsEntries(int cnt) 

Method Source Code

//package com.java2s;
/** TestsHelper.java -//w  w w  .  java  2  s .  com
* @version      $Name$
* @module       my.apache.ignite.examples.utils
* 
* @purpose
* @see
*
* @author   Kamal (kamal@nmsworks.co.in)
*
* @created  Jul 12, 2016
* $Id$
*
* @bugs
*
* Copyright 2016-2017 NMSWorks Software Pvt Ltd. All rights reserved.
* NMSWorks PROPRIETARY/CONFIDENTIAL. Use is subject to licence terms.
*/

import java.util.HashMap;
import java.util.Map;
import java.util.Random;

public class Main {
    private static final String LETTERS_ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    private static final Random RANDOM = new Random(System.currentTimeMillis());

    public static Map<String, String> generateStringsEntries(int cnt) {
        Map<String, String> map = new HashMap<>();
        for (int i = 0; i < cnt; i++) {
            map.put(Integer.toString(i), randomString(5));
        }
        return map;
    }

    public static String randomString(int len) {
        StringBuilder builder = new StringBuilder(len);

        for (int i = 0; i < len; i++)
            builder.append(LETTERS_ALPHABET.charAt(RANDOM.nextInt(LETTERS_ALPHABET.length())));

        return builder.toString();
    }
}

Related

  1. GenerateString(int Length)
  2. generateString(int maxlength)
  3. generateString(String alphabet, int length)
  4. generateString(String charSet, int len)
  5. generateStrings(int count, int length)
  6. getDummyPassword()