Advertisement
TizzyT

Random BigInteger Generator - TizzyT

Feb 16th, 2014
1,150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 0.43 KB | None | 0 0
  1. ''' Random BigInteger Generator '''
  2.     Private Function RandBigInt(ByVal BitLength As BigInteger, ByRef Rnd As Random) As BigInteger
  3.         Dim Rmdr, numParts(BigInteger.DivRem(BitLength, 8, Rmdr)) As Byte
  4.         For i = 0 To numParts.Length - 2 : numParts(i) = Rnd.Next(0, 256) : Next
  5.         numParts(numParts.Length - 1) = If(Rmdr = 0, 0, Rnd.Next(0, 2 ^ Rmdr - 1))
  6.         RandBigInt = New BigInteger(numParts)
  7.     End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement