Package java.util

Examples of java.util.Random.nextBytes()


    @Test
    public void testSerialize() throws IOException, StorageFormatException, ResumeFailedException, GeneralSecurityException, ClassNotFoundException {
        File tempFile = File.createTempFile("test-storeto", ".tmp", base);
        byte[] buf = new byte[4096];
        Random r = new Random(1267612);
        r.nextBytes(buf);
        FileBucket fb = new FileBucket(tempFile, false, false, false, true);
        EncryptedRandomAccessBucket erab = new EncryptedRandomAccessBucket(types[0], fb, secret);
        OutputStream os = erab.getOutputStream();
        os.write(buf, 0, buf.length);
        os.close();
View Full Code Here


    FSDataOutputStream stm = fileSys.create(name, true,
                                            fileSys.getConf().getInt("io.file.buffer.size", 4096),
                                            (short)repl, (long)blockSize);
    byte[] buffer = new byte[fileSize];
    Random rand = new Random(seed);
    rand.nextBytes(buffer);
    stm.write(buffer);
    stm.close();
  }

  private void checkFile(FileSystem fileSys, Path name, int repl)
View Full Code Here

    FSDataOutputStream stm = fileSys.create(name, true,
                                            fileSys.getConf().getInt("io.file.buffer.size", 4096),
                                            (short)repl, (long)blockSize);
    byte[] buffer = new byte[fileSize];
    Random rand = new Random(seed);
    rand.nextBytes(buffer);
    stm.write(buffer);
    stm.close();
  }
 
 
View Full Code Here

      Random r = new Random(y.nextLong());
      byte[] msg = new byte[32];
      long[] timeSigning = new long[1000];
      long[] timeVerifying = new long[timeSigning.length];
      for(int i=0;i<timeSigning.length;i++) {
        r.nextBytes(msg);
        BigInteger m = new BigInteger(1, msg);
        pk = new DSAPrivateKey(g, r);
        int privKeySize = pk.asBytes().length;
        totalPrivKeySize += privKeySize;
        if(privKeySize > maxPrivKeySize) maxPrivKeySize = privKeySize;
View Full Code Here

            sz = (int)padding;
          byte[] buf = new byte[sz];
          long writtenPadding = 0;
          while(writtenPadding < padding) {
            int left = (int) Math.min((long) (padding - writtenPadding), (long) buf.length);
            random.nextBytes(buf);
            out.write(buf, 0, left);
            writtenPadding += left;
          }
        }
      } finally {
View Full Code Here

      int scale = random.nextInt(19) + 1;
      int size = random.nextInt(1 << scale);

      // build 5k array
      byte[] originalUncompressedData = new byte[size];
      random.nextBytes(originalUncompressedData);

      byte[] compressedData = doCompress(originalUncompressedData);
      byte[] outUncompressedData = new byte[size];

      int writtenBytes = 0;
View Full Code Here

        ArrayBucket input = new ArrayBucket();
        BucketTools.fill(input, 2048);
        int keysize = 16;
        Random random = new Random(0x47f6709f);
        byte[] key = new byte[keysize];
        random.nextBytes(key);
        Bucket output = new ArrayBucket();
        OutputStream os = output.getOutputStream();
        AEADOutputStream cos = AEADOutputStream.innerCreateAES(os, key, random);
        BucketTools.copyTo(input, cos, 2048);
        cos.close();
View Full Code Here

        ArrayBucket input = new ArrayBucket();
        BucketTools.fill(input, 1024);
        int keysize = 16;
        Random random = new Random(0x47f6709f);
        byte[] key = new byte[keysize];
        random.nextBytes(key);
        Bucket output = new ArrayBucket();
        OutputStream os = output.getOutputStream();
        AEADOutputStream cos = AEADOutputStream.innerCreateAES(new NoCloseProxyOutputStream(os), key, random);
        BucketTools.copyTo(input, cos, -1);
        cos.close();
View Full Code Here

    @Test
    public void testStoreTo() throws IOException, StorageFormatException, ResumeFailedException, GeneralSecurityException {
        File tempFile = File.createTempFile("test-storeto", ".tmp", base);
        byte[] buf = new byte[4096];
        Random r = new Random(1267612);
        r.nextBytes(buf);
        FileRandomAccessBuffer rafw = new FileRandomAccessBuffer(tempFile, buf.length+types[0].headerLen, false);
        EncryptedRandomAccessBuffer eraf = new EncryptedRandomAccessBuffer(types[0], rafw, secret, true);
        eraf.pwrite(0, buf, 0, buf.length);
        byte[] tmp = new byte[buf.length];
        eraf.pread(0, tmp, 0, buf.length);
View Full Code Here

    @Test
    public void testSerialize() throws IOException, StorageFormatException, ResumeFailedException, GeneralSecurityException, ClassNotFoundException {
        File tempFile = File.createTempFile("test-storeto", ".tmp", base);
        byte[] buf = new byte[4096];
        Random r = new Random(1267612);
        r.nextBytes(buf);
        FileRandomAccessBuffer rafw = new FileRandomAccessBuffer(tempFile, buf.length+types[0].headerLen, false);
        EncryptedRandomAccessBuffer eraf = new EncryptedRandomAccessBuffer(types[0], rafw, secret, true);
        eraf.pwrite(0, buf, 0, buf.length);
        byte[] tmp = new byte[buf.length];
        eraf.pread(0, tmp, 0, buf.length);
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.