本文整理匯總了C#中Org.BouncyCastle.Security.SecureRandom.NextLong方法的典型用法代碼示例。如果您正苦於以下問題:C# SecureRandom.NextLong方法的具體用法?C# SecureRandom.NextLong怎麽用?C# SecureRandom.NextLong使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Org.BouncyCastle.Security.SecureRandom
的用法示例。
在下文中一共展示了SecureRandom.NextLong方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Bip38Intermediate
/// <summary>
/// Create an intermediate from a passphrase or intermediate code
/// </summary>
public Bip38Intermediate(string fromstring, Interpretation interpretation, int startingSequenceNumber = 0)
{
if (interpretation == Interpretation.IntermediateCode) {
createFromCode(fromstring);
} else {
_ownerentropy = new byte[8];
// Get 8 random bytes to use as salt
SecureRandom sr = new SecureRandom();
sr.NextBytes(_ownerentropy);
// set lot number between 100000 and 999999, and sequence number to 1
long x = (sr.NextLong () % 900000L + 100000L) * 4096L + (long)startingSequenceNumber;
for (int i=7; i>=4; i--) {
_ownerentropy[i] = (byte)(x & 0xFF);
x >>= 8;
}
createFromPassphrase(fromstring, _ownerentropy, true);
}
}
示例2: Create
/// <summary>
/// Creates a new random key pair, using a user-provided string to add entropy to the
/// SecureRandom generator provided by the .NET Framework.
/// </summary>
public static KeyPair Create(string usersalt, bool compressed=false, byte addressType = 0)
{
if (usersalt == null) usersalt = "ok, whatever";
usersalt += DateTime.UtcNow.Ticks.ToString();
SecureRandom sr = new SecureRandom();
byte[] poop = Util.ComputeSha256(usersalt + nonce.ToString());
nonce++;
byte[] newkey = new byte[32];
for (int i = 0; i < 32; i++) {
long x = sr.NextLong() & long.MaxValue;
x += poop[i];
newkey[i] = (byte)(x & 0xff);
}
return new KeyPair(newkey, compressed: compressed, addressType: addressType);
}