Package java.security

Examples of java.security.SecureRandom.nextInt()


                break;

            case HASH_METHOD_CRYPT:
                salt = new byte[2];
                SecureRandom sr = new SecureRandom();
                int i1 = sr.nextInt( 64 );
                int i2 = sr.nextInt( 64 );

                salt[0] = ( byte ) ( i1 < 12 ? ( i1 + '.' ) : i1 < 38 ? ( i1 + 'A' - 12 ) : ( i1 + 'a' - 38 ) );
                salt[1] = ( byte ) ( i2 < 12 ? ( i2 + '.' ) : i2 < 38 ? ( i2 + 'A' - 12 ) : ( i2 + 'a' - 38 ) );
                break;
View Full Code Here


            case HASH_METHOD_CRYPT:
                salt = new byte[2];
                SecureRandom sr = new SecureRandom();
                int i1 = sr.nextInt( 64 );
                int i2 = sr.nextInt( 64 );

                salt[0] = ( byte ) ( i1 < 12 ? ( i1 + '.' ) : i1 < 38 ? ( i1 + 'A' - 12 ) : ( i1 + 'a' - 38 ) );
                salt[1] = ( byte ) ( i2 < 12 ? ( i2 + '.' ) : i2 < 38 ? ( i2 + 'A' - 12 ) : ( i2 + 'a' - 38 ) );
                break;
View Full Code Here

    static String generateHash() {
        StringBuffer sb = new StringBuffer();
        Random rand = new SecureRandom();
        for (int i = 0; i < 32; i++) {
            sb.append(CHARS.charAt(Math.abs(rand.nextInt()) % CHARS.length()));
        }

        return sb.toString();
    }
View Full Code Here

            ShamirsSecretSharing.SecretShare[] some = new ShamirsSecretSharing.SecretShare[n];
            Set<Integer> pick = new HashSet<Integer> ();
            while ( pick.size () < n )
            {
              int p = random.nextInt (s);
              if ( !pick.contains (p) )
              {
                some[pick.size ()] = all[p];
                pick.add (p);
              }
View Full Code Here

            List<String> some = new ArrayList<> ();
            Set<Integer> pick = new HashSet<Integer> ();
            while ( pick.size () < n )
            {
              int p = random.nextInt (s);
              if ( !pick.contains (p) )
              {
                some.add (all.get (p));
                pick.add (p);
              }
View Full Code Here

    protected String createSecKey() {
        SecureRandom random = new SecureRandom();
        byte[] data = new byte[16];
        for (int i = 0; i < 4; ++i) {
            int val = random.nextInt();
            data[i * 4] = (byte) val;
            data[i * 4 + 1] = (byte) ((val >> 8) & 0xFF);
            data[i * 4 + 2] = (byte) ((val >> 16) & 0xFF);
            data[i * 4 + 3] = (byte) ((val >> 24) & 0xFF);
        }
View Full Code Here

        final SecureRandom secureRandom = new SecureRandom();
        testSingleInstanceConcurrency(100, new RedissonRunnable() {
            @Override
            public void run(Redisson redisson) {
                ConcurrentMap<Integer, Integer> map = redisson.getMap(name);
                map.replace(secureRandom.nextInt(5), 2);
            }
        });

        ConcurrentMap<Integer, Integer> testMap = Redisson.create().getMap(name);
        for (Integer value : testMap.values()) {
View Full Code Here

        final SecureRandom secureRandom = new SecureRandom();
        testMultiInstanceConcurrency(100, new RedissonRunnable() {
            @Override
            public void run(Redisson redisson) {
                ConcurrentMap<String, String> map = redisson.getMap(name);
                map.remove(secureRandom.nextInt(10), 1);
            }
        });

        assertMapSize(0, name);
    }
View Full Code Here

        ConcurrentFlusher[] flushers = new ConcurrentFlusher[50000];
        FutureCallback[] futures = new FutureCallback[flushers.length];
        for (int i = 0; i < flushers.length; i++)
        {
            int size = 5 + random.nextInt(15);
            ByteArrayEndPoint endp = new ByteArrayEndPoint(new byte[]{}, size);

            final ConcurrentFlusher flusher = new ConcurrentFlusher(endp, random, scheduler);
            flushers[i] = flusher;
            final FutureCallback callback = new FutureCallback();
View Full Code Here

                public void run()
                {
                    flusher.onFail(new Throwable("THE CAUSE"));
                }
            }
                    , random.nextInt(75) + 1, TimeUnit.MILLISECONDS);
            flusher.write(callback, BufferUtil.toBuffer("How Now Brown Cow."), BufferUtil.toBuffer(" The quick brown fox jumped over the lazy dog!"));
        }

        int completed = 0;
        int failed = 0;
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.