Changeset df8cd90


Ignore:
Timestamp:
Nov 23, 2011 10:10:34 PM (8 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
5a93405
Parents:
f3e2dfac
Message:
Location:
core/java/src/net/i2p/util
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • core/java/src/net/i2p/util/FortunaRandomSource.java

    rf3e2dfac rdf8cd90  
    149149    public synchronized void nextBytes(byte buf[]) {
    150150        _fortuna.nextBytes(buf);
     151    }
     152
     153    /**
     154     * Not part of java.util.SecureRandom, but added for efficiency, since Fortuna supports it.
     155     *
     156     * @since 0.8.12
     157     */
     158    @Override
     159    public synchronized void nextBytes(byte buf[], int offset, int length) {
     160        _fortuna.nextBytes(buf, offset, length);
    151161    }
    152162
  • core/java/src/net/i2p/util/RandomSource.java

    rf3e2dfac rdf8cd90  
    6060     * thats what it has been used for.
    6161     *
     62     * This code unused, see FortunaRandomSource override
    6263     */
    6364    @Override
     
    7374     * Like the modified nextInt, nextLong(n) returns a random number from 0 through n,
    7475     * including 0, excluding n.
     76     *
     77     * This code unused, see FortunaRandomSource override
    7578     */
    7679    public long nextLong(long n) {
     
    7982        if (v >= n) v = v % n;
    8083        return v;
     84    }
     85
     86    /**
     87     * Not part of java.util.SecureRandom, but added since Fortuna supports it.
     88     *
     89     * This code unused, see FortunaRandomSource override
     90     *
     91     * @since 0.8.12
     92     */
     93    public void nextBytes(byte buf[], int offset, int length) {
     94        // inefficient, just in case anybody actually instantiates this
     95        if (offset == 0 && buf.length == length) {
     96            nextBytes(buf);
     97        } else {
     98            byte[] tmp = new byte[length];
     99            nextBytes(tmp);
     100            System.arraycopy(tmp, 0, buf, offset, length);
     101        }
    81102    }
    82103
     
    189210    }
    190211
     212/****
    191213    public static void main(String args[]) {
    192214        for (int j = 0; j < 2; j++) {
     
    209231        }
    210232    }
     233****/
    211234}
Note: See TracChangeset for help on using the changeset viewer.