Extract() public méthode

public Extract ( int num ) : byte[]
num int
Résultat byte[]
Exemple #1
0
 private Object FromNetValueType(Type tp)
 {
     byte[] data = Buffer.Extract(Globs.SizeOf(tp));
     if (Repr == DataRepresentation.Tpm)
     {
         return(Globs.NetToHostValue(tp, data));
     }
     if (Repr == DataRepresentation.LittleEndian)
     {
         return(Globs.FromBytes(tp, data));
     }
     // Unsupported type
     Debug.Assert(false);
     return(null);
 }
Exemple #2
0
 public static byte[] GetRandomBytes(int numBytes)
 {
     if (numBytes > RandMaxBytes)
     {
         throw new Exception("Too many random bytes requested.");
     }
     // Make sure that the RNG is properly seeded
     if (_randSeed == null)
     {
         SetRngRandomSeed();
     }
     // Fill or refill the buffer
     lock (RandLock)
     {
         // ReSharper disable once PossibleNullReferenceException
         if (_randBuf == null || _randBuf.BytesRemaining() < numBytes)
         {
             FillRandBuf();
         }
         // And return the data
         return(_randBuf.Extract(numBytes));
     }
 }
 /// <summary>
 /// Retrives the requested number of pseudo-random bytes from the internal pool,
 /// and replenishes it, if necessary.
 /// </summary>
 public byte[] GetRandomBytes(int numBytes)
 {
     if (numBytes > RandMaxBytes)
     {
         Globs.Throw <ArgumentException>("GetRandomBytes: Too many bytes requested " + numBytes);
         numBytes = RandMaxBytes;
     }
     // Make sure that the RNG is properly seeded
     if (Seed == null)
     {
         SetRngRandomSeed();
     }
     // Fill or refill the buffer
     lock (this)
     {
         // ReSharper disable once PossibleNullReferenceException
         if (Buf.BytesRemaining() < numBytes)
         {
             FillRandBuf();
         }
         // And return the data
         return(Buf.Extract(numBytes));
     }
 }