Example usage for org.bouncycastle.crypto.prng RandomGenerator addSeedMaterial

List of usage examples for org.bouncycastle.crypto.prng RandomGenerator addSeedMaterial

Introduction

In this page you can find the example usage for org.bouncycastle.crypto.prng RandomGenerator addSeedMaterial.

Prototype

void addSeedMaterial(long seed);

Source Link

Document

Add more seed material to the generator.

Usage

From source file:net.sourceforge.keepassj2me.keydb.KeydbDatabase.java

License:Open Source License

protected int getRandom() {
    byte[] id = new byte[4];
    RandomGenerator rnd = new DigestRandomGenerator(new SHA1Digest());
    rnd.addSeedMaterial(System.currentTimeMillis());
    rnd.nextBytes(id);/*w  w w. j  a  va  2s . co m*/
    return (id[0] | (id[1] << 8) | (id[2] << 16) | (id[3] << 24));
}

From source file:net.sourceforge.keepassj2me.keydb.KeydbEntry.java

License:Open Source License

/**
 * Generate entry uuid//from w w w .j a  v  a 2 s .co  m
 * @return uuid
 */
public byte[] createUUID() {//FIXME: make sure this is unique
    byte[] uuid = new byte[16];
    RandomGenerator rnd = new DigestRandomGenerator(new SHA1Digest());
    rnd.addSeedMaterial(System.currentTimeMillis());
    rnd.nextBytes(uuid);
    return uuid;
}

From source file:net.sourceforge.keepassj2me.keydb.KeydbHeader.java

License:Open Source License

/**
 * Reinitialize header//from   w  ww .  j  a va  2  s . c om
 * @param rounds
 */
public void reinitialize(int rounds) {
    numKeyEncRounds = rounds;
    //SecureRandom rnd = SecureRandom.getInstance("SHA1PRNG");
    //rnd.setSeed(System.currentTimeMillis());
    RandomGenerator rnd = new DigestRandomGenerator(new SHA1Digest());
    rnd.addSeedMaterial(System.currentTimeMillis());
    rnd.nextBytes(masterSeed);
    rnd.nextBytes(encryptionIV);
    rnd.nextBytes(masterSeed2);
}