All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.adobe.acs.commons.util.impl.SecureRandomStringUtils Maven / Gradle / Ivy

There is a newer version: 6.6.0
Show newest version
/*
 * #%L
 * ACS AEM Commons Bundle
 * %%
 * Copyright (C) 2017 Adobe
 * %%
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * #L%
 */
package com.adobe.acs.commons.util.impl;

import org.apache.commons.lang.RandomStringUtils;

import java.security.SecureRandom;

/**
 * Utility class for generating random string using SecureRandom
 */
public class SecureRandomStringUtils {

    private SecureRandomStringUtils() {
    }

    /**
     * 

Random object used by random method. This has to be not local * to the random method so as to not return the same value in the * same millisecond.

*/ private static final SecureRandom RANDOM = new SecureRandom(); /** *

Creates a random string whose length is the number of characters * specified.

* *

Characters will be chosen from the set of Latin alphabetic * characters (a-z, A-Z) and the digits 0-9.

* * @param count the length of random string to create * @return the random string */ public static String randomAlphanumeric(final int count) { return RandomStringUtils.random(count, 0, 0, true, true, null, RANDOM); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy