Package java.security

Examples of java.security.SecureRandom.nextBytes()


        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 {
View Full Code Here


            public Object run(SqlJetDb db) throws SqlJetException {
                final ISqlJetCursor c = t.open();
                try {
                    if (!c.eof()) {
                        do {
                            rnd.nextBytes(blob);

                            try {
                                c.update(rnd.nextInt(2048), blob);
                            } catch (SqlJetException e) {
                                if (!SqlJetErrorCode.CONSTRAINT.equals(e.getErrorCode())) {
View Full Code Here

                        if(null==argthrow misuse;
                        if( arg instanceof Integer ){
                            final Integer numBytes = (Integer) arg;
                            if( 0>=numBytes ) throw misuse;
                            final byte[] bytes = new byte[numBytes];
                            random.nextBytes(bytes);
                            return bytes;
                        } else throw misuse;
                    }
                }
            );
View Full Code Here

        SecureRandom rnd = new SecureRandom();
        ISqlJetTable table = db.getTable("tiles");
        for (int i = 0; i < INSERTS_COUNT; i++) {
            byte[] blob = new byte[1024 + rnd.nextInt(4096)];
            rnd.nextBytes(blob);

            int x = rnd.nextInt(2048);
            int y = 0;
            int zoom = 10;
            db.beginTransaction(SqlJetTransactionMode.WRITE);
View Full Code Here

            int remainder = baos.size() % 4; //if it wasn't a 4 byte inet address
            if (remainder > 0)
            {
                int pad = 4 - remainder;
                byte[] pad_bytes = new byte[pad];
                srand.nextBytes(pad_bytes);
                dos.write(pad_bytes);
            }
           
            StringBuffer sb = new StringBuffer(32);
            byte[] vmid_bytes = baos.toByteArray();
View Full Code Here

             if (login!=null&&password!=null&&login.length()<=100){
                 // Uses a secure Random not a simple Random
                 SecureRandom random = SecureRandom.getInstance("SHA1PRNG");
                 // Salt generation 64 bits long
                 byte[] bSalt = new byte[8];
                 random.nextBytes(bSalt);
                 // Digest computation
                 byte[] bDigest = getHash(ITERATION_NUMBER,password,bSalt);
                 String sDigest = byteToBase64(bDigest);
                 String sSalt = byteToBase64(bSalt);
  
View Full Code Here

      //ignore the failure, we're just trying to come up with a random seed
    }
    byte[] rand = byteOut.toByteArray();

    SecureRandom randomizer = new SecureRandom(rand);
    randomizer.nextBytes(address);

    // set the MSB of the first octet to 1 to distinguish from IEEE node addresses
    address[0] = (byte) (address[0] | (byte) 0x80);

    return address;
View Full Code Here

    @Override
    public AESCTRNoPaddingEncryptor build() {
      ByteBuffer buffer = ByteBuffer.allocate(16);
      byte[] seed = new byte[12];
      SecureRandom random = new SecureRandom();
      random.nextBytes(seed);
      buffer.put(seed).putInt(1);
      return new AESCTRNoPaddingEncryptor(key, buffer.array());
    }
  }
View Full Code Here

     */
    public static String randomUUID() {
        byte[] data;
        // lock on the class to protect lazy init
        SecureRandom rng = new SecureRandom();
        rng.nextBytes(data = new byte[16]);
        long mostSigBits = (data[0] & 0xFFL) << 56;
        mostSigBits |= (data[1] & 0xFFL) << 48;
        mostSigBits |= (data[2] & 0xFFL) << 40;
        mostSigBits |= (data[3] & 0xFFL) << 32;
        mostSigBits |= (data[4] & 0xFFL) << 24;
View Full Code Here

        // set new salt value, if we didn't have any.
        if (getSystemPasswordSalt().isEmpty()) {
            LOG.debug("Generating new salt for LDAP system password.");
            final SecureRandom random = new SecureRandom();
            byte[] saltBytes = new byte[8];
            random.nextBytes(saltBytes);
            setSystemPasswordSalt(Hex.encodeToString(saltBytes));
        }
        final String encrypted = AESTools.encrypt(
                systemPassword,
                configuration.getPasswordSecret().substring(0, 16),
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.