Package freenet.support.math

Examples of freenet.support.math.MersenneTwister


public class CryptUtilTest extends TestCase {

  public void testRandomBytes()
  {
    // two predictable pseudo-random sequence
    MersenneTwister mt1 = new MersenneTwister(Long.MAX_VALUE);
    MersenneTwister mt2 = new MersenneTwister(Long.MAX_VALUE);

    for(int off = 0; off < 15; off++) {
      for(int len = 0; len < 31; len++) {
        byte[] b1 = new byte[len];
        byte[] b2 = new byte[len + off];
View Full Code Here


        fetcher.setSplitfileBlocks(splitfileDataBlocks + totalCrossCheckBlocks, splitfileCheckBlocks);
       
        keyListener.finishedSetup();
       
        if(crossCheckBlocks != 0) {
            Random crossSegmentRandom = new MersenneTwister(Metadata.getCrossSegmentSeed(metadata.getHashes(), metadata.getHashThisLayerOnly()));
            // Cross segment redundancy: Allocate the blocks.
            crossSegments = new SplitFileFetcherCrossSegmentStorage[segments.length];
            int segLen = blocksPerSegment;
            int deductBlocksFromSegments = metadata.getDeductBlocksFromSegments();
            for(int i=0;i<crossSegments.length;i++) {
View Full Code Here

    totalInputSinceStartup = fs.getLong("totalInput", 0);
    totalOutputSinceStartup = fs.getLong("totalOutput", 0);

    byte buffer[] = new byte[16];
    node.random.nextBytes(buffer);
    paddingGen = new MersenneTwister(buffer);
   
    if(fromLocal) {
      SimpleFieldSet f = fs.subset("full");
      if(fullFieldSet == null && f != null)
        fullFieldSet = f;
View Full Code Here

        if (crossCheckBlocks != 0) {
            byte[] seed = Metadata.getCrossSegmentSeed(hashes, hashThisLayerOnly);
            if (logMINOR)
                Logger.minor(this, "Cross-segment seed: " + HexUtil.bytesToHex(seed));
            Random xsRandom = new MersenneTwister(seed);
            // Cross segment redundancy: Allocate the blocks.
            crossSegments = new SplitFileInserterCrossSegmentStorage[segs];
            int segLen = segmentSize;
            for (int i = 0; i < crossSegments.length; i++) {
                if (logMINOR)
View Full Code Here

          metaFC.write(bf, oldMetaLen);
          oldMetaLen += 4096;
        }
        byte[] seed = new byte[64];
        random.nextBytes(seed);
        Random mt = new MersenneTwister(seed);
        int x = 0;
        while (currentHdLen < newHdLen) {
          mt.nextBytes(b);
          bf.rewind();
          hdFC.write(bf, currentHdLen);
          currentHdLen += 4096;
          if(currentHdLen % (1024*1024*1024L) == 0) {
            random.nextBytes(seed);
            mt = new MersenneTwister(seed);
            if (starting) {
              WrapperManager.signalStarting((int) MINUTES.toMillis(5));
              if ( x++ % 32 == 0 )
                System.err.println("Preallocating space for " + name + ": " + currentHdLen + "/" + newHdLen);
            }
View Full Code Here

    isPRNGReady = true;
    toadlets.getStartupToadlet().setIsPRNGReady();
    if(weakRandom == null) {
      byte buffer[] = new byte[16];
      random.nextBytes(buffer);
      this.fastWeakRandom = new MersenneTwister(buffer);
    }else
      this.fastWeakRandom = weakRandom;

    nodeNameUserAlert = new MeaningfulNodeNameUserAlert(this);
    this.config = config;
View Full Code Here


  public MersenneTwister createRandom() {
    byte[] buf = new byte[16];
    random.nextBytes(buf);
    return new MersenneTwister(buf);
  }
View Full Code Here

TOP

Related Classes of freenet.support.math.MersenneTwister

Copyright © 2018 www.massapicom. 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.