Java XML Data Type Converter generateSalt()

Here you can find the source of generateSalt()

Description

generate Salt

License

Open Source License

Declaration

public static String generateSalt() 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.security.SecureRandom;

import javax.xml.bind.DatatypeConverter;

public class Main {
    public static String generateSalt() {
        return random(32);
    }/*from  w  w  w. j a v  a 2  s .co m*/

    public static String random(final int length) {
        final byte[] salt = new byte[length];
        new SecureRandom().nextBytes(salt);
        return hex(salt);
    }

    public static String hex(final byte[] bytes) {
        return DatatypeConverter.printHexBinary(bytes);
    }

    public static byte[] hex(final String str) {
        return DatatypeConverter.parseHexBinary(str);
    }
}

Related

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