com.adobe.acs.commons.util.impl.SecureRandomStringUtils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of acs-aem-commons-bundle Show documentation
Show all versions of acs-aem-commons-bundle Show documentation
Main ACS AEM Commons OSGi Bundle. Includes commons utilities.
/*
* ACS AEM Commons
*
* Copyright (C) 2013 - 2023 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.
*/
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