"Sputnik" help  
Sputnik Help
BinaryRandom(<binary>, [<seed>], [<start>], [<length>])

Description

The BinaryRandom function generates a random binary string based on the specified parameters.

Parameters

<binary> The binary string used as a template to generate the random string.
<seed> Optional seed value used for random number generation. If not specified, a default seed value is used.
<start> Optional starting index within the <binary> string to generate the random portion. It can be a positive or negative value. A negative value indicates counting from the end of the binary string.
<length> Optional length of the random portion to generate. If not specified, the entire length of the <binary> string is used.

Return Value

Success: Returns a new binary string with random content based on the specified parameters.
Failure: Returns an empty binary string.

Remarks

The BinaryRandom function generates a random binary string based on the specified <binary> string, seed value, starting index, and length.
If the <seed> is not provided, a default seed value is used for random number generation.
The <start> parameter indicates the starting index within the <binary> string from which the random portion will be generated. It can be a positive or negative value. A negative value counts from the end of the binary string.
The <length> parameter specifies the length of the random portion to generate. If not specified, the entire length of the <binary> string is used.
The original <binary> string is not modified; instead, a new binary string is created with the random content.
The generated random content is based on the specified parameters and is suitable for general purposes but may not have strong cryptographic security.

Related

Example

Example of usage:

my $template = BinaryFromStr("Hello");
my $random1 = BinaryRandom($template);
my $random2 = BinaryRandom($template, 12345);
my $random3 = BinaryRandom($template, 54321, -3, 2);
my $random4 = BinaryRandom($template, 54321, 1, 3);
BinaryExpandPrintLn($random1, false);
BinaryExpandPrintLn($random2, false);
BinaryExpandPrintLn($random3, false);
BinaryExpandPrintLn($random4, false);
// PRINTS
// 32 CE 51 ED 12 -- -- -- -- -- -- -- -- -- -- -- 2ÎQí.
// C5 5B 56 E6 8B -- -- -- -- -- -- -- -- -- -- -- Å[Væ.
// 48 65 0C E6 6F -- -- -- -- -- -- -- -- -- -- -- He.æo
// 48 0C E6 C1 6F -- -- -- -- -- -- -- -- -- -- -- H.æÁo

 


Contact
Cheryl (uberfox@hotmail.com)
Homepage
http://ubersoft.org