Examples of SecureRandom


Examples of java.security.SecureRandom

  *
  * @return random string
  */
  private static String generateRandomString() {
    final StringBuffer res = new StringBuffer();
    final Random rnd = new SecureRandom();
    for (int i = 0; i < 32; i++) {
      int pos = (int) (rnd.nextFloat() * CHARS.length());
      res.append(CHARS.charAt(pos));
    }
 
    return res.toString();
  }
View Full Code Here

Examples of java.security.SecureRandom

            // create the 20 bytes seed

            byte[] seed = new byte[20];

            KeyGenerator key = KeyGenerator.getInstance("AES");           
            key.init(192, new SecureRandom());
            SecretKey sk = key.generateKey();           
            System.arraycopy(sk.getEncoded(), 0, seed, 0, 20); // create the 20 bytes seed
               
           
            Iterator it = policy.getRecipientsIterator();
View Full Code Here

Examples of java.security.SecureRandom

                db.createTable(T_DDL);
                return true;
            }
        });

        final SecureRandom rnd = new SecureRandom();
        final ISqlJetTable t = db.getTable("t");
        final byte[] blob = new byte[1024 + 4096];

        rnd.nextBytes(blob);

        db.runWriteTransaction(new ISqlJetTransaction() {
            public Object run(SqlJetDb db) throws SqlJetException {

                try {
                    t.insert(rnd.nextInt(2048), blob);
                } catch (SqlJetException e) {
                    if (!SqlJetErrorCode.CONSTRAINT.equals(e.getErrorCode())) {
                        throw 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.