Increased output block size from 64 to 96 bytes; now using 8 counter values, instead...
[fast-key-erasure-rng-java.git] / src / io / github / deajl3ka / fast_key_erasure / Main.java
blobb45b549639e24812b8406aa9b98cf00af293428c
1 /*
2 * FastKeyErasureRNG: Fast-key-erasure random-number generator for Java
3 * Copyright (c) 2023 "dEajL3kA" <Cumpoing79@web.de>
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
6 * associated documentation files (the "Software"), to deal in the Software without restriction,
7 * including without limitation the rights to use, copy, modify, merge, publish, distribute,
8 * sub license, and/or sell copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions: The above copyright notice and this
10 * permission notice shall be included in all copies or substantial portions of the Software.
12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
13 * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
14 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
15 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
16 * OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
18 package io.github.deajl3ka.fast_key_erasure;
20 import java.io.FileDescriptor;
21 import java.io.FileOutputStream;
22 import java.io.IOException;
24 public class Main {
26 public static void main(String[] args) {
27 final short[] libVersion = FastKeyErasureRNG.getVersion();
28 System.err.printf("%s [v%d.%d]%n", FastKeyErasureRNG.class.getSimpleName(), libVersion[0], libVersion[1]);
29 final FastKeyErasureRNG random = FastKeyErasureRNG.current();
30 final byte[] buffer = new byte[4096];
31 try (final FileOutputStream output = new FileOutputStream(FileDescriptor.out)) {
32 for (;;) {
33 random.nextBytes(buffer);
34 try {
35 output.write(buffer);
36 } catch (final IOException e) {
37 break;
40 } catch (final Exception e) {
41 System.err.println("Something went wrong: " + e);