Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
RandomBytes.cs
1using System;
2using System.Numerics;
3using System.Security.Cryptography;
8
10{
15 {
25 {
26 }
27
31 public override string FunctionName => nameof(RandomBytes);
32
40 {
41 int N = (int)Argument;
42 if (N != Argument || N < 0)
43 throw new ScriptRuntimeException("Number of bytes must be non-negative.", this);
44
45 byte[] Bin = new byte[N];
46
47 lock (rnd)
48 {
49 rnd.GetBytes(Bin);
50 }
51
52 return new ObjectValue(Bin);
53 }
54
55 private static readonly RandomNumberGenerator rnd = RandomNumberGenerator.Create();
56
57 }
58}
Generates an array of random bytes.
Definition: RandomBytes.cs:15
RandomBytes(ScriptNode Argument, int Start, int Length, Expression Expression)
Generates an array of random bytes.
Definition: RandomBytes.cs:23
override IElement EvaluateScalar(double Argument, Variables Variables)
Evaluates the function on a scalar argument.
Definition: RandomBytes.cs:39
override string FunctionName
Name of the function
Definition: RandomBytes.cs:31
Class managing a script expression.
Definition: Expression.cs:39
Base class for funcions of one scalar variable.
ScriptNode Argument
Function argument.
Base class for all nodes in a parsed script tree.
Definition: ScriptNode.cs:69
int Length
Length of expression covered by node.
Definition: ScriptNode.cs:101
int Start
Start position in script expression.
Definition: ScriptNode.cs:92
Collection of variables.
Definition: Variables.cs:25
Basic interface for all types of elements.
Definition: IElement.cs:20