Ubuntu Manpages

Crypt::PRNG::RC4

Legacy RC4-based PRNG wrapper

   ### Functional interface:
   use Crypt::PRNG::RC4 qw(random_bytes random_bytes_hex random_bytes_b64 random_bytes_b64u random_string random_string_from rand irand);
   my $octets = random_bytes(45);
   my $hex_string = random_bytes_hex(45);
   my $base64_string = random_bytes_b64(45);
   my $base64url_string = random_bytes_b64u(45);
   my $alphanumeric_string = random_string(30);
   my $string = random_string_from('ACGT', 64);
   my $floating_point_number_0_to_1 = rand;
   my $floating_point_number_0_to_88 = rand(88);
   my $unsigned_32bit_int = irand;
   ### OO interface:
   use Crypt::PRNG::RC4;
   my $prng = Crypt::PRNG::RC4->new;
   my $seeded_prng = Crypt::PRNG::RC4->new("some data used for seeding PRNG");
   my $octets = $prng->bytes(45);
   my $hex_string = $prng->bytes_hex(45);
   my $base64_string = $prng->bytes_b64(45);
   my $base64url_string = $prng->bytes_b64u(45);
   my $alphanumeric_string = $prng->string(30);
   my $string = $prng->string_from('ACGT', 64);
   my $floating_point_number_0_to_1 = $prng->double;
   my $floating_point_number_0_to_88 = $prng->double(88);
   my $unsigned_32bit_int = $prng->int32;

Provides an interface to the RC4-based pseudo-random number generator.

This is a thin wrapper around Crypt::PRNG with the algorithm fixed to RC4. All functions and methods accept the same arguments and return the same values as the corresponding Crypt::PRNG entries.

RC4 is provided for compatibility with legacy code only and is not recommended for new designs.

Nothing is exported by default.

You can export selected functions:

  use Crypt::PRNG::RC4 qw(random_bytes random_string);

Or all of them at once:

  use Crypt::PRNG::RC4 ':all';

All functions below behave exactly like the corresponding Crypt::PRNG functions, but use a hidden "Crypt::PRNG::RC4" object internally.

See "random_bytes" in Crypt::PRNG.

See "random_bytes_hex" in Crypt::PRNG.

See "random_bytes_b64" in Crypt::PRNG.

See "random_bytes_b64u" in Crypt::PRNG.

See "random_string" in Crypt::PRNG.

See "random_string_from" in Crypt::PRNG.

See "rand" in Crypt::PRNG.

See "irand" in Crypt::PRNG.

Unless noted otherwise, assume $prng is an existing "Crypt::PRNG::RC4" object created via "new".

 my $prng = Crypt::PRNG::RC4->new;
 my $seeded_prng = Crypt::PRNG::RC4->new($seed);

Creates a PRNG object using the RC4 algorithm. If $seed is omitted, the object is automatically seeded by the underlying Crypt::PRNG logic. If $seed is provided it must be at least 5 bytes long; empty or shorter seeds fail during initialization.

See "bytes" in Crypt::PRNG.

See "bytes_hex" in Crypt::PRNG.

See "bytes_b64" in Crypt::PRNG.

See "bytes_b64u" in Crypt::PRNG.

See "string" in Crypt::PRNG.

See "string_from" in Crypt::PRNG.

See "double" in Crypt::PRNG.

See "int32" in Crypt::PRNG.

  • Crypt::PRNG
  • <https://en.wikipedia.org/wiki/RC4_cipher>