SecureString icon indicating copy to clipboard operation
SecureString copied to clipboard

Avoid allocating array just to fill secure buffer

Open westonal opened this issue 8 years ago • 0 comments

    private static void populateBufferWithSecureKeyData(ByteBuffer key) {
        final Random random = new SecureRandom();
        final byte bytes[] = new byte[key.capacity()];
        random.nextBytes(bytes);
        key.put(bytes);
        Arrays.fill(bytes, (byte) 0);
    }

westonal avatar Oct 16 '17 11:10 westonal