Examples of generateSeed()


Examples of java.security.SecureRandom.generateSeed()

        // generator "self seeds".  If a setSeed() is called before
        // any nextBytes call, no self seeding is done.  We use the
        // self seeding and our own bytes.
       
        // Access the internal seed generator.
        byte[] seed1 = sRandom.generateSeed(16) ;
        byte[] seed2 = LibUUID.makeSeed() ;
        // seeds are cumulative
        sRandom.setSeed(seed1) ;                    
        sRandom.setSeed(seed2) ;                    
        return sRandom ;
View Full Code Here

Examples of java.security.SecureRandom.generateSeed()

   * */
  public static byte[] getSalt() throws Exception {
    // 实例化安全随机数
    SecureRandom random = new SecureRandom();
    // 产出盐
    return random.generateSeed(8);
  }

  public static byte[] getStaticSalt() {
    // 产出盐
    return Salt.getBytes();
View Full Code Here

Examples of java.security.SecureRandom.generateSeed()

            // and afterwards (in the thread) using the regular algorithm.
            Runnable runnable = new Runnable() {
                public void run() {
                    try {
                        SecureRandom sr = SecureRandom.getInstance("SHA1PRNG");
                        byte[] seed = sr.generateSeed(20);
                        synchronized (cachedSecureRandom) {
                            cachedSecureRandom.setSeed(seed);
                            seeded = true;
                        }
                    } catch (Exception e) {
View Full Code Here

Examples of java.security.SecureRandom.generateSeed()

    new SecureRandom(seed).nextBytes(new byte[20]);
  }

  public final void testGenerateSeed() {
    SecureRandom sr = new SecureRandom();
    byte[] seed = sr.generateSeed(5);
    new SecureRandom(seed).nextBytes(new byte[20]);
  }
}
View Full Code Here

Examples of java.security.SecureRandom.generateSeed()

        if (hashAlgo == null) {
            int hash = CryptoFunctions.createXorVerifier1(password);
            cur.insertAttributeWithValue(getAttrName(prefix, "password"), Integer.toHexString(hash).toUpperCase());
        } else {
            SecureRandom random = new SecureRandom();
            byte salt[] = random.generateSeed(16);
   
            // Iterations specifies the number of times the hashing function shall be iteratively run (using each
            // iteration's result as the input for the next iteration).
            int spinCount = 100000;
View Full Code Here

Examples of java.security.SecureRandom.generateSeed()

            final BlockingQueue<byte[]> queue = new LinkedBlockingQueue<byte[]>();
            Thread generatorThread = new Thread("initialSeedUniquifierGenerator") {
                @Override
                public void run() {
                    SecureRandom random = new SecureRandom(); // Get the real random seed from /dev/random
                    queue.add(random.generateSeed(8));
                }
            };
            generatorThread.setDaemon(true);
            generatorThread.start();
            generatorThread.setUncaughtExceptionHandler(new UncaughtExceptionHandler() {
View Full Code Here

Examples of java.security.SecureRandom.generateSeed()

            // and afterwards (in the thread) using the regular algorithm.
            Runnable runnable = new Runnable() {
                public void run() {
                    try {
                        SecureRandom sr = SecureRandom.getInstance("SHA1PRNG");
                        byte[] seed = sr.generateSeed(20);
                        synchronized (cachedSecureRandom) {
                            cachedSecureRandom.setSeed(seed);
                            seeded = true;
                        }
                    } catch (Exception e) {
View Full Code Here

Examples of java.security.SecureRandom.generateSeed()

        if (seed != null) {
            secureRandom = new SecureRandom(Base64Util.base64toByte(seed));
        } else {
            secureRandom = new SecureRandom();
            secureRandom.setSeed(secureRandom.generateSeed(32));
        }

        KeyGenerator kg = getKeyGenerator(algorithm);
        if (keySize <= 0) {
            kg.init(secureRandom);
View Full Code Here

Examples of java.security.SecureRandom.generateSeed()

public class SeedGeneratorChoice {

    public static void main(String... arguments) throws Exception {
        byte[] bytes;
        SecureRandom prng = SecureRandom.getInstance("SHA1PRNG");
        bytes = prng.generateSeed(1);
    }
}
View Full Code Here

Examples of java.security.SecureRandom.generateSeed()

     * @return
     */
    private SecureRandom createSecureRandom(String algorithm, String provider, int keyLength) {
        try {
            SecureRandom random = SecureRandom.getInstance(algorithm, provider);
            random.setSeed(random.generateSeed(keyLength));
            return random;
        } catch (NoSuchAlgorithmException e) {
            throw new IllegalArgumentException("Not a supported SecureRandom key generation algorithm", e);
        } catch (NoSuchProviderException e) {
            throw new IllegalArgumentException("Not a supported SecureRandom key provider", e);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.