Java XML Data Type Converter generateSalt(int clientNonceByteCount)

Here you can find the source of generateSalt(int clientNonceByteCount)

Description

generate Salt

License

Open Source License

Declaration

public static String generateSalt(int clientNonceByteCount) 

Method Source Code


//package com.java2s;
/*/*w w  w . j a  v a 2  s. co m*/
 * Copyright (C) 2015 - 2016 Emmanuel Tourdot
 *
 * See the NOTICE file distributed with this work for additional information regarding copyright ownership.
 * This is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser
 * General Public License as published by the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
 * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License along with this software.
 * If not, see <http://www.gnu.org/licenses/>.
 *
 */

import javax.xml.bind.DatatypeConverter;

import java.security.SecureRandom;

public class Main {
    private static SecureRandom randomGenerator;

    public static String generateSalt(int clientNonceByteCount) {
        final byte[] salt = new byte[clientNonceByteCount];
        randomGenerator.nextBytes(salt);
        return DatatypeConverter.printHexBinary(salt).toLowerCase();
    }
}

Related

  1. fetchUrl(String url, String username, String password)
  2. formatFriendlyName(final byte[] addressBytes)
  3. fromString(String s)
  4. fromStringSafe(final String s)
  5. generateSalt()
  6. getByteList(String nomal, boolean isDecode)
  7. getByteListStr(List byteList, boolean isEncode)
  8. getDataUrlForBytes(final byte[] bytes)
  9. getImgurContent(String clientID, byte[] image)