@Test public void testRotation() { final RotatingNonceGenerator generator = new RotatingNonceGenerator(2); final byte[] r1 = generator.next(); final byte[] r2 = generator.next(); final byte[] r3 = generator.next(); assertFalse(Arrays.equals(r1, r2)); assertArrayEquals(r1, r3); }
@Override public byte[] next() { if(index >= capacity) { index = 0; } if(nonces.size() <= index) { final byte[] nonce = new byte[len]; random.nextBytes(nonce); nonces.add(nonce); } return nonces.get(index++); }
RotatingNonceGenerator implements NonceGenerator { @Override public byte[] next() { if(index >= capacity) { index = 0; } if(nonces.size() <= index) { final byte[] nonce = new byte[len]; random.nextBytes(nonce); nonces.add(nonce); } return nonces.get(index++); } }
RotatingNonceGenerator implements NonceGenerator { @Override public byte[] next() { if(index >= capacity) { index = 0; } if(nonces.size() <= index) { final byte[] nonce = new byte[len]; random.nextBytes(nonce); nonces.add(nonce); } return nonces.get(index++); } RotatingNonceGenerator(final int capacity); }
RotatingNonceGenerator implements NonceGenerator { @Override public byte[] next() { if(index >= capacity) { index = 0; } if(nonces.size() <= index) { final byte[] nonce = new byte[len]; random.nextBytes(nonce); nonces.add(nonce); } return nonces.get(index++); } RotatingNonceGenerator(final int capacity); @Override byte[] next(); @Override String toString(); }
RotatingNonceGenerator implements NonceGenerator { @Override public byte[] next() { if(index >= capacity) { index = 0; } if(nonces.size() <= index) { final byte[] nonce = new byte[len]; random.nextBytes(nonce); nonces.add(nonce); } return nonces.get(index++); } RotatingNonceGenerator(final int capacity); @Override byte[] next(); @Override String toString();  }